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

Error.cause is not inspect-formatted when printed by console.log #23416

Closed
exe-dealer opened this issue Apr 17, 2024 · 1 comment · Fixed by #24526
Closed

Error.cause is not inspect-formatted when printed by console.log #23416

exe-dealer opened this issue Apr 17, 2024 · 1 comment · Fixed by #24526
Labels
bug Something isn't working correctly ext/console Related to the ext/console crate good first issue Good for newcomers

Comments

@exe-dealer
Copy link

$ deno --version
deno 1.42.4 (release, x86_64-unknown-linux-gnu)
v8 12.3.219.9
typescript 5.4.3
// $ cat example.js
const err = Error('boom', {
  cause: {
    code: 100500,
  },
});

console.log(err);

actual behavior

$ deno run example.js
Error: boom
    at file:///home/v.nezhutin/pgwire/example.js:1:13
Caused by [object Object]

expected behavior

$ deno run example.js
Error: boom
    at file:///home/v.nezhutin/pgwire/example.js:1:13
Caused by: { code: 100500 }
@exe-dealer exe-dealer changed the title Error.cause is not inspect-formated when printed by console.log Error.cause is not inspect-formatted when printed by console.log Apr 17, 2024
@exe-dealer
Copy link
Author

mdn says that its ok to use non Error object as Error.cause https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#providing_structured_data_as_the_error_cause

@lucacasonato lucacasonato added bug Something isn't working correctly good first issue Good for newcomers ext/console Related to the ext/console crate labels Jun 8, 2024
bartlomieju pushed a commit that referenced this issue Jul 22, 2024
)

This pull request addresses an issue where the Error.cause property was
not formatted correctly when printed using console.log, leading to
confusion.

solution:
Implemented a fix to ensure that Error.cause is formatted properly when
printed by console.log, and the fix done by using JSON.stringify

This PR fixes #23416

---------

Signed-off-by: MujahedSafaa <168719085+MujahedSafaa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly ext/console Related to the ext/console crate good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants