-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
doc: add clarification for exception behaviour #25339
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
Changes from 1 commit
79bc97c
9b16424
b4783ca
73fa299
450ee9c
39b0ca3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -527,6 +527,17 @@ exception is pending and no additional action is required. If the | |
instead of simply returning immediately, [`napi_is_exception_pending`][] | ||
must be called in order to determine if an exception is pending or not. | ||
|
||
In many cases when an N-API function is called and an exception is | ||
already pending the function will return immediately with a | ||
`napi_status` of `napi_pending_exception`. However, this is not the case | ||
for all functions. N-API allows a subset of the functions to be | ||
called in order to allow for some minimal cleanup to be completed | ||
mhdawson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
before returning to JavaScript. For those functions, `napi_status` | ||
will reflect the success/error/exception for that function, irrespective of | ||
whether an exception was pending when the function was called. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence is difficult to understand. "for that function" is particularly confusing coming after "for those functions". Maybe try writing it as two shorter sentences or something? Or just tidying up the sentence that's there somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe something like this? In that case, `napi_status` will reflect the status for the function.
It will not reflect previous pending exceptions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Obviously, change my suggestion if it is factually incorrect. I'm commenting on style and readability, not content.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your suggestion works for me. Updating. |
||
In order to avoid confusion it is important to check the | ||
mhdawson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
error status after every function call. | ||
|
||
When an exception is pending one of two approaches can be employed. | ||
|
||
The first approach is to do any appropriate cleanup and then return so that | ||
|
Uh oh!
There was an error while loading. Please reload this page.