Make getStack to clean up event when error occurs
This commit is contained in:
parent
fa7a168f17
commit
f51f4e2aad
10
src/base.ts
10
src/base.ts
@ -391,7 +391,7 @@ export function withColor(color: Colors, value: any): ColorFormat {
|
|||||||
function getStack() {
|
function getStack() {
|
||||||
// Save original Error.prepareStackTrace
|
// Save original Error.prepareStackTrace
|
||||||
let origPrepareStackTrace = (<any>Error).prepareStackTrace;
|
let origPrepareStackTrace = (<any>Error).prepareStackTrace;
|
||||||
|
try {
|
||||||
// Override with function that just returns `stack`
|
// Override with function that just returns `stack`
|
||||||
(<any>Error).prepareStackTrace = function (_, stack) {
|
(<any>Error).prepareStackTrace = function (_, stack) {
|
||||||
return stack;
|
return stack;
|
||||||
@ -403,13 +403,11 @@ function getStack() {
|
|||||||
// Evaluate `err.stack`, which calls our new `Error.prepareStackTrace`
|
// Evaluate `err.stack`, which calls our new `Error.prepareStackTrace`
|
||||||
let stack: any[] = <any>err.stack;
|
let stack: any[] = <any>err.stack;
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
} finally {
|
||||||
// Restore original `Error.prepareStackTrace`
|
// Restore original `Error.prepareStackTrace`
|
||||||
(<any>Error).prepareStackTrace = origPrepareStackTrace;
|
(<any>Error).prepareStackTrace = origPrepareStackTrace;
|
||||||
|
}
|
||||||
// Remove superfluous function call on stack
|
|
||||||
stack.shift(); // getStack --> Error
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function baseName(path) {
|
function baseName(path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user