MCPcopy
hub / github.com/processing/p5.js / printFriendlyStack

Function printFriendlyStack

src/core/friendly_errors/fes_core.js:477–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475 * @param {Array} friendlyStack
476 */
477 const printFriendlyStack = friendlyStack => {
478 const log =
479 p5._fesLogger && typeof p5._fesLogger === 'function'
480 ? p5._fesLogger
481 : console.log.bind(console);
482 if (friendlyStack.length > 1) {
483 let stacktraceMsg = '';
484 friendlyStack.forEach((frame, idx) => {
485 const location = `${frame.fileName}:${frame.lineNumber}:${
486 frame.columnNumber
487 }`;
488 let frameMsg,
489 translationObj = {
490 func: frame.functionName,
491 line: frame.lineNumber,
492 location,
493 file: frame.fileName.split('/').slice(-1)
494 };
495 if (idx === 0) {
496 frameMsg = translator('fes.globalErrors.stackTop', translationObj);
497 } else {
498 frameMsg = translator('fes.globalErrors.stackSubseq', translationObj);
499 }
500 stacktraceMsg += frameMsg;
501 });
502 log(stacktraceMsg);
503 }
504 };
505
506 /**
507 * Takes a stacktrace array and filters out all frames that show internal p5

Callers 2

processStackFunction · 0.85
fesErrorMonitorFunction · 0.85

Calls 3

translatorFunction · 0.90
sliceMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected