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

refactor(core): add more information when unable to build error #17027

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

bartlomieju
Copy link
Member

This should help debug problem in #16963

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - one comment that probably needs an issue first.

let cb = cb.open(tc_scope);
let this = v8::undefined(tc_scope).into();
let class = v8::String::new(tc_scope, get_class(error)).unwrap();
let message = v8::String::new(tc_scope, &format!("{:#}", error)).unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is interesting. I didn't notice that we format the rust errors using the Debug trait. Debug traits might include sensitive information (crypto material, file paths, platform info) - we should be more careful with type_error and generic_error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is on purpose, otherwise the error includes only the first line which loses a lot of context in different scenarios. @dsherret we use that in Node compat IIRC?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it had a question mark it would be debug. The {:#} is "alternate" form of printing https://doc.rust-lang.org/std/fmt/#sign0 -- with anyhow it includes the context.

@bartlomieju bartlomieju merged commit 3551955 into denoland:main Dec 13, 2022
@bartlomieju bartlomieju deleted the add_error_to_error_builder branch December 13, 2022 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants