Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2757,6 +2757,22 @@ inline Error::Error(napi_env env, napi_value value)
nullptr};

status = napi_define_properties(env, wrappedErrorObj, 1, &wrapObjFlag);
#ifdef NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS
if (status == napi_pending_exception) {
// Test if the pending exception was reported because the environment is
// shutting down. We assume that a status of napi_pending_exception
// coupled with the absence of an actual pending exception means that
// the environment is shutting down. If so, we replace the
// napi_pending_exception status with napi_ok.
bool is_exception_pending = false;
status = napi_is_exception_pending(env, &is_exception_pending);
if (status == napi_ok && !is_exception_pending) {
status = napi_ok;
} else {
status = napi_pending_exception;
}
}
#endif // NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS
NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_define_properties");

// Create a reference on the newly wrapped object
Expand Down