Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
n-api: napi_make_callback error handling
Browse files Browse the repository at this point in the history
Updated error handling to return `napi_pending_exception` when the
target of the callback call throws.
  • Loading branch information
kfarnung committed Mar 20, 2018
1 parent b7d8e8f commit aadf3a8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/node_api_jsrt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2159,8 +2159,14 @@ napi_status napi_make_callback(napi_env env,
node::MakeCallback(isolate, v8recv, v8func, argc, v8argv,
*node_async_context);

bool hasException;
CHECK_JSRT(JsHasException(&hasException));
if (hasException) {
return napi_set_last_error(napi_pending_exception);
}

if (v8result.IsEmpty()) {
return napi_set_last_error(napi_generic_failure);
return napi_set_last_error(napi_generic_failure);
}

if (result != nullptr) {
Expand Down

0 comments on commit aadf3a8

Please sign in to comment.