Created
July 19, 2019 17:32
-
-
Save yaroschiffelers/eda926a880afca0a64e1ea637acf917e to your computer and use it in GitHub Desktop.
Enhance Stack Trace Method (from nodejs/node/lib/events.js)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function enhanceStackTrace(err, own) { | |
| const sep = '\nEmitted \'error\' event at:\n'; | |
| const errStack = err.stack.split('\n').slice(1); | |
| const ownStack = own.stack.split('\n').slice(1); | |
| const [ len, off ] = identicalSequenceRange(ownStack, errStack); | |
| if (len > 0) { | |
| ownStack.splice(off + 1, len - 2, | |
| ' [... lines matching original stack trace ...]'); | |
| } | |
| return err.stack + sep + ownStack.join('\n'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment