diff options
author | Michael Dawson <michael_dawson@ca.ibm.com> | 2019-01-04 09:47:27 -0500 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-01-09 05:38:03 +0100 |
commit | b406c9c4e95e6e90c43df843512a4c761ad9affa (patch) | |
tree | ca13d7f4d3f664847f9261aea473721980988926 /doc/api/n-api.md | |
parent | ccc06a3c3291546c777da74cd3bdff903b33c607 (diff) | |
download | android-node-v8-b406c9c4e95e6e90c43df843512a4c761ad9affa.tar.gz android-node-v8-b406c9c4e95e6e90c43df843512a4c761ad9affa.tar.bz2 android-node-v8-b406c9c4e95e6e90c43df843512a4c761ad9affa.zip |
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: https://github.com/nodejs/node/pull/25339
Refs: https://github.com/nodejs/abi-stable-node/issues/356
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'doc/api/n-api.md')
-rw-r--r-- | doc/api/n-api.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 1a02711f8e..bcda526f87 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -527,6 +527,15 @@ 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 to allow for some minimal cleanup before returning to JavaScript. +In that case, `napi_status` will reflect the status for the function. It +will not reflect previous pending exceptions. To avoid confusion, check +the 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 |