-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
Labels
errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
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
BridgeAR, himself65, sindresorhus, ex1st and aditya1944
Metadata
Metadata
Assignees
Labels
errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.