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

fix(napi): functions related to errors #17370

Merged
merged 19 commits into from
Jan 15, 2023

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Jan 12, 2023

This commits fixes various NAPI functions related to creation and throwing
of errors.

Comment on lines +262 to +263
check_env!(env);
let env = unsafe { &mut *env };
Copy link
Member

Choose a reason for hiding this comment

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

Why this instead of just let env: &mut Env = env.as_mut().ok_or(Error::InvalidArg)?;

Copy link
Member Author

Choose a reason for hiding this comment

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

Because .as_mut() consumes the pointer and makes it impossible to create a value out of scope, assign it to the result pointer and later call a function like napi_clear_error_code

cli/napi/js_native_api.rs Outdated Show resolved Hide resolved
cli/napi/js_native_api.rs Outdated Show resolved Hide resolved
@bartlomieju bartlomieju marked this pull request as ready for review January 14, 2023 14:44
@bartlomieju bartlomieju changed the title [WIP] fix(napi): functions related to errors fix(napi): functions related to errors Jan 14, 2023
@bartlomieju bartlomieju enabled auto-merge (squash) January 14, 2023 15:05
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!

@bartlomieju bartlomieju merged commit df8bfa2 into denoland:main Jan 15, 2023
@bartlomieju bartlomieju deleted the napi_error_tests branch January 15, 2023 12:57
bartlomieju added a commit that referenced this pull request Jan 16, 2023
This commits fixes various NAPI functions related to creation and
throwing of errors.
MierenManz added a commit to MierenManz/oned that referenced this pull request Jan 20, 2023
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

2 participants