diff --git a/doc/error_handling.md b/doc/error_handling.md index 709d5aedd..7063f5548 100644 --- a/doc/error_handling.md +++ b/doc/error_handling.md @@ -14,8 +14,8 @@ If C++ exceptions are enabled (for more info see: [Setup](setup.md)), then the `Napi::Error` class extends `std::exception` and enables integrated error-handling for C++ exceptions and JavaScript exceptions. -Note, that due to limitations of the N-API, if one attempt to cast the error object thrown as a primitive, an -wrapped object will be received instead. (With properties ```isWrapObject``` and ```errorVal``` containing the primitive value thrown) +Note, that due to limitations of the N-API, if one attempts to cast the error object wrapping a primitive inside a C++ addon, the wrapped object +will be received instead. (With properties ```4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject``` and ```errorVal``` containing the primitive value thrown) The following sections explain the approach for each case: diff --git a/napi-inl.h b/napi-inl.h index d70eb3428..3e15697d0 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -2512,10 +2512,12 @@ inline Error::Error(napi_env env, napi_value value) : ObjectReference(env, nullp Value::From(env, value)); NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property"); - status = napi_set_property(env, - wrappedErrorObj, - String::From(env, "isWrapObject"), - Value::From(env, value)); + status = napi_set_property( + env, + wrappedErrorObj, + String::From(env, + "4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"), + Value::From(env, value)); NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property"); status = napi_create_reference(env, wrappedErrorObj, 1, &_ref); @@ -2539,7 +2541,10 @@ inline Object Error::Value() const { // We are checking if the object is wrapped bool isWrappedObject = false; napi_has_property( - _env, refValue, String::From(_env, "isWrapObject"), &isWrappedObject); + _env, + refValue, + String::From(_env, "4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"), + &isWrappedObject); // Don't care about status if (isWrappedObject == true) {