StarlingMonkey
StarlingMonkey copied to clipboard
Support Error.cause in logging
When reporting errors that have a "cause"
property (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause), we should not just print the error itself but also nicely print the cause of the error.
For example with code like throw new Error('blah', { cause: new Error('other') })
, browsers return:
Error: blah
at <anonymous>:1:1
Caused by: Error: other
at <anonymous>:1:28
and Node.js will return:
Error: blah
at REPL3:1:1
at ContextifyScript.runInThisContext (node:vm:137:12)
... 7 lines matching cause stack trace ...
at [_line] [as _line] (node:internal/readline/interface:887:18) {
[cause]: Error: other
at REPL3:1:28
at ContextifyScript.runInThisContext (node:vm:137:12)
at REPLServer.defaultEval (node:repl:598:22)
at bound (node:domain:432:15)
Would be great to add first-class support in our error logging further.