| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 01749f0 commit 528798c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2811,11 +2811,15 @@ napi_status napi_make_callback(napi_env env, | |||
| 2811 | 2811 | isolate, v8recv, v8func, argc, | |
| 2812 | 2812 | reinterpret_cast<v8::Local<v8::Value>*>(const_cast<napi_value*>(argv)), | |
| 2813 | 2813 | *node_async_context); | |
| 2814 | - CHECK_MAYBE_EMPTY(env, callback_result, napi_generic_failure); | ||
| 2815 | 2814 | ||
| 2816 | - if (result != nullptr) { | ||
| 2817 | - *result = v8impl::JsValueFromV8LocalValue( | ||
| 2818 | - callback_result.ToLocalChecked()); | ||
| 2815 | + if (try_catch.HasCaught()) { | ||
| 2816 | + return napi_set_last_error(env, napi_pending_exception); | ||
| 2817 | + } else { | ||
| 2818 | + CHECK_MAYBE_EMPTY(env, callback_result, napi_generic_failure); | ||
| 2819 | + if (result != nullptr) { | ||
| 2820 | + *result = v8impl::JsValueFromV8LocalValue( | ||
| 2821 | + callback_result.ToLocalChecked()); | ||
| 2822 | + } | ||
| 2819 | 2823 | } | |
| 2820 | 2824 | ||
| 2821 | 2825 | return GET_RETURN_STATUS(env); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,9 +13,22 @@ napi_value MakeCallback(napi_env env, napi_callback_info info) { | |||
| 13 | 13 | napi_value recv = args[0]; | |
| 14 | 14 | napi_value func = args[1]; | |
| 15 | 15 | ||
| 16 | - napi_make_callback(env, nullptr /* async_context */, | ||
| 16 | + napi_status status = napi_make_callback(env, nullptr /* async_context */, | ||
| 17 | 17 | recv, func, 0 /* argc */, nullptr /* argv */, nullptr /* result */); | |
| 18 | 18 | ||
| 19 | + bool isExceptionPending; | ||
| 20 | + NAPI_CALL(env, napi_is_exception_pending(env, &isExceptionPending)); | ||
| 21 | + if (isExceptionPending && !(status == napi_pending_exception)) { | ||
| 22 | + // if there is an exception pending we don't expect any | ||
| 23 | + // other error | ||
| 24 | + napi_value pending_error; | ||
| 25 | + status = napi_get_and_clear_last_exception(env, &pending_error); | ||
| 26 | + NAPI_CALL(env, | ||
| 27 | + napi_throw_error((env), | ||
| 28 | + nullptr, | ||
| 29 | + "error when only pending exception expected")); | ||
| 30 | + } | ||
| 31 | + | ||
| 19 | 32 | return recv; | |
| 20 | 33 | } | |
| 21 | 34 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments