MCPcopy Index your code
hub / github.com/nodejs/node / enhanceStackTrace

Function enhanceStackTrace

lib/events.js:424–447  ·  view source on GitHub ↗
(err, own)

Source from the content-addressed store, hash-verified

422};
423
424function enhanceStackTrace(err, own) {
425 let ctorInfo = '';
426 try {
427 const { name } = this.constructor;
428 if (name !== 'EventEmitter')
429 ctorInfo = ` on ${name} instance`;
430 } catch {
431 // Continue regardless of error.
432 }
433 const sep = `\nEmitted 'error' event${ctorInfo} at:\n`;
434
435 const errStack = ArrayPrototypeSlice(
436 StringPrototypeSplit(err.stack, '\n'), 1);
437 const ownStack = ArrayPrototypeSlice(
438 StringPrototypeSplit(own.stack, '\n'), 1);
439
440 const { len, offset } = identicalSequenceRange(ownStack, errStack);
441 if (len > 0) {
442 ArrayPrototypeSplice(ownStack, offset + 1, len - 2,
443 ' [... lines matching original stack trace ...]');
444 }
445
446 return err.stack + sep + ArrayPrototypeJoin(ownStack, '\n');
447}
448
449/**
450 * Synchronously calls each of the listeners registered

Callers

nothing calls this directly

Calls 1

identicalSequenceRangeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…