You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better support for Error.cause in util.inspect/console.log #40859
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)
...
I implemented something locally. It always prints the non-enumerable cause property and hides duplicated stack frames as long as they are included in the causing error stack as well. @targos does this match your needs?
Activity
BridgeAR commentedon Nov 24, 2021
I implemented something locally. It always prints the non-enumerable
causeproperty and hides duplicated stack frames as long as they are included in the causing error stack as well. @targos does this match your needs?targos commentedon Nov 25, 2021
Looks good to me!
kanongil commentedon Nov 28, 2021
There is already a bit of discussion on this here: #38725 (comment)
util: always visualize cause property in errors during inspection
util: always visualize cause property in errors during inspection
util: always visualize cause property in errors during inspection
util: always visualize cause property in errors during inspection
util: always visualize cause property in errors during inspection