-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Support Error.prototype.cause
#13260
Comments
We should definitely add this, yeah! I added support to our logger at work just a few weeks ago 😀 PR welcome, most changes should be in https://github.com/facebook/jest/blob/d1626e9395263b0c7c207777c0ca570b2147aaa8/packages/jest-message-util/src/index.ts |
As errors in |
And like node, duplicate traces should be removed. $ node -p "new Error('asdasd', {cause: new Error('cause')})"
Error: asdasd
at [eval]:1:1
at Script.runInThisContext (node:vm:129:12)
... 4 lines matching cause stack trace ...
at node:internal/main/eval_string:27:3 {
[cause]: Error: cause
at [eval]:1:29
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:313:38)
at node:internal/process/execution:76:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:75:60)
at node:internal/main/eval_string:27:3
} (note Not necessary for an initial implementation, of course |
$ node -e "console.log(util.inspect(new Error('asdasd', {cause: new Error('cause')})))"
Error: asdasd
at [eval]:1:26
at Script.runInThisContext (node:vm:129:12)
... 4 lines matching cause stack trace ...
at node:internal/main/eval_string:27:3 {
[cause]: Error: cause
at [eval]:1:54
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at node:internal/process/execution:76:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:75:60)
at node:internal/main/eval_string:27:3
} |
Related change there is nodejs/node#41002. |
I can take this up if no one has started work @SimenB |
Go for it! 🙂 |
Hey apologies, I am starting work on this today. I got caught in some other work. |
Duplicate of #12053. PR is of course still very much welcome! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Some new APIs like
fetch
make use ofError.prototype.cause
which jest does not display at all for thrown errors, which makes debugging these errors harder than necessary.Motivation
It will make errors with
cause
easier to debug.Example
Will output only the wrapped error message, which is often unhelpful:
It'd be better if the
cause
message would also be shown:Pitch
Because
Error.prototype.cause
is a standard Javascript feature.The text was updated successfully, but these errors were encountered: