node/test/addons-napi/test_exception
Gabriel Schulhof e6ccdfbde3 n-api: ensure in-module exceptions are propagated
Whenever we call into an addon, whether it is for a callback, for
module init, or for async work-related reasons, we should make sure
that

* the last error is cleared,
* the scopes before the call are the same as after, and
* if an exception was thrown and captured inside the module, then it is
  re-thrown after the call.

Therefore we should call into the module in a unified fashion. This
change introduces the macro NAPI_CALL_INTO_MODULE() which should be
used whenever invoking a callback provided by the module.

Fixes: https://github.com/nodejs/node/issues/19437
Backport-PR-URL: https://github.com/nodejs/node/pull/19447
PR-URL: https://github.com/nodejs/node/pull/19537
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-04-16 17:46:19 -04:00
..
binding.gyp n-api: add support for abi stable module API 2018-04-16 17:45:48 -04:00
test.js n-api: ensure in-module exceptions are propagated 2018-04-16 17:46:19 -04:00
test_exception.c n-api: ensure in-module exceptions are propagated 2018-04-16 17:46:19 -04:00