Closed
Description
Is your feature request related to a problem? Please describe.
Given this code:
const one = new Error('one');
const two = new Error('two', { cause: one });
const three = new Error('three', { cause: two });
console.log(three);
Error: three
at Object.<anonymous> (/test.js:3:15)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
...
The output only contains the error message and stack for error three.
It is already possible to see the value of cause
, when showHidden
is enabled, but in my opinion this is not a good general solution because it makes the output too verbose and requires to set a global config for console.log
.
Describe the solution you'd like
I'm open to suggestions. One idea I have is to output something recursively indented like this:
Error: three
at Object.<anonymous> (/test.js:3:15)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
...
Caused by:
Error: two
at Object.<anonymous> (/test.js:2:13)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
...
Caused by:
Error: one
at Object.<anonymous> (/test.js:1:13)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
...
/cc @nodejs/util