Make getStack to clean up event when error occurs

This commit is contained in:
Fabian Stamm 2020-04-11 15:05:17 +02:00
parent fa7a168f17
commit f51f4e2aad

View File

@ -391,7 +391,7 @@ export function withColor(color: Colors, value: any): ColorFormat {
function getStack() {
// Save original Error.prepareStackTrace
let origPrepareStackTrace = (<any>Error).prepareStackTrace;
try {
// Override with function that just returns `stack`
(<any>Error).prepareStackTrace = function (_, stack) {
return stack;
@ -403,13 +403,11 @@ function getStack() {
// Evaluate `err.stack`, which calls our new `Error.prepareStackTrace`
let stack: any[] = <any>err.stack;
return stack;
} finally {
// Restore original `Error.prepareStackTrace`
(<any>Error).prepareStackTrace = origPrepareStackTrace;
// Remove superfluous function call on stack
stack.shift(); // getStack --> Error
return stack;
}
}
function baseName(path) {