Error is printed with `cause` property
Opened this issue · 0 comments
teststaybaka commented
Hi,
I was trying this amazing library out but noticed the output is a little different than documented. I pasted the code I tried as below.
import ChainedCustomError from "typescript-chained-error";
let e = new ChainedCustomError(
"ddd",
new ChainedCustomError("sss", new Error("hahah"))
);
console.error(e);
The output somehow includes cause
property.
ChainedError: ddd
at Object.<anonymous> (~/nested_error/temp.js:8:9)
Caused by: ChainedError: sss
at Object.<anonymous> (~/nested_error/temp.js:8:55)
Caused by: Error: hahah
at Object.<anonymous> (~/nested_error/temp.js:8:101) {
cause: ChainedError: sss
at Object.<anonymous> (~/nested_error/temp.js:8:55)
Caused by: Error: hahah
at Object.<anonymous> (~/nested_error/temp.js:8:101) {
cause: Error: hahah
at Object.<anonymous> (/home/.../nested_error/temp.js:8:101)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
}
}
If you do throw
, the output is the same. Do you think there is a way to omit cause:
? Thanks!
I'm running under node v12.14.1, compiled with TypeScript Version 4.1.5.