Skip to content
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

Inspection of error with cause fails for non-error causes #41096

Closed
targos opened this issue Dec 6, 2021 · 1 comment
Closed

Inspection of error with cause fails for non-error causes #41096

targos opened this issue Dec 6, 2021 · 1 comment
Labels
confirmed-bug Issues with confirmed bugs. util Issues and PRs related to the built-in util module.

Comments

@targos
Copy link
Member

targos commented Dec 6, 2021

Version

master

Platform

N/A

Subsystem

util

What steps will reproduce the bug?

./node -p "new Error('test', { cause: 42 })"

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

It should be able to serialize non-error causes.

What do you see instead?

$ ./node -p "new Error('test', { cause: 42 })"
node:internal/util/inspect:1194
  return error.stack ? String(error.stack) : ErrorPrototypeToString(error);
                                             ^

TypeError: Method Error.prototype.toString called on incompatible receiver 42
    at Number.toString (<anonymous>)
    at getStackString (node:internal/util/inspect:1194:46)
    at getStackFrames (node:internal/util/inspect:1202:24)
    at formatError (node:internal/util/inspect:1284:19)
    at formatRaw (node:internal/util/inspect:943:14)
    at formatValue (node:internal/util/inspect:798:10)
    at inspect (node:internal/util/inspect:345:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2140:40)
    at formatWithOptions (node:internal/util/inspect:2006:10)
    at console.value (node:internal/console/constructor:323:14)

Node.js v18.0.0-pre

Additional information

No response

@targos targos added confirmed-bug Issues with confirmed bugs. util Issues and PRs related to the built-in util module. labels Dec 6, 2021
@targos
Copy link
Member Author

targos commented Dec 6, 2021

/cc @BridgeAR

BridgeAR added a commit to BridgeAR/node that referenced this issue Dec 6, 2021
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: nodejs#41096

Signed-off-by: Ruben Bridgewater <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this issue Dec 6, 2021
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: nodejs#41096

Signed-off-by: Ruben Bridgewater <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this issue Dec 6, 2021
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: nodejs#41096

Signed-off-by: Ruben Bridgewater <[email protected]>
nodejs-github-bot pushed a commit that referenced this issue Dec 11, 2021
Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Fixes: #41096
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Dec 14, 2021
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: #41096

Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Dec 14, 2021
Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Fixes: #41096
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Jan 31, 2022
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: #41096

Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Jan 31, 2022
Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Fixes: #41096
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Jan 31, 2022
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: #41096

Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Jan 31, 2022
Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Fixes: #41096
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Linkgoron pushed a commit to Linkgoron/node that referenced this issue Jan 31, 2022
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: nodejs#41096

Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: nodejs#41097
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Linkgoron pushed a commit to Linkgoron/node that referenced this issue Jan 31, 2022
Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: nodejs#41097
Fixes: nodejs#41096
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Feb 1, 2022
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.

Fixes: #41096

Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
danielleadams pushed a commit that referenced this issue Feb 1, 2022
Signed-off-by: Ruben Bridgewater <[email protected]>

PR-URL: #41097
Fixes: #41096
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant