Skip to content

Commit 66ab7e4

Browse files
mhdawsonMylesBorins
authored andcommitted
doc: add clarification for exception behaviour
Document current behaviour where some methods can be called when an exception is pending, while others cannot and explain the behaviour. PR-URL: #25339 Refs: nodejs/abi-stable-node#356 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent ce3cf0d commit 66ab7e4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/api/n-api.md

+9
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,15 @@ exception is pending and no additional action is required. If the
468468
instead of simply returning immediately, [`napi_is_exception_pending`][]
469469
must be called in order to determine if an exception is pending or not.
470470

471+
In many cases when an N-API function is called and an exception is
472+
already pending, the function will return immediately with a
473+
`napi_status` of `napi_pending_exception`. However, this is not the case
474+
for all functions. N-API allows a subset of the functions to be
475+
called to allow for some minimal cleanup before returning to JavaScript.
476+
In that case, `napi_status` will reflect the status for the function. It
477+
will not reflect previous pending exceptions. To avoid confusion, check
478+
the error status after every function call.
479+
471480
When an exception is pending one of two approaches can be employed.
472481

473482
The first approach is to do any appropriate cleanup and then return so that

0 commit comments

Comments
 (0)