Skip to content

Commit 02bcfbc

Browse files
committed
Update doc and appending GUID to object property
1 parent c89f0bf commit 02bcfbc

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/error_handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ If C++ exceptions are enabled (for more info see: [Setup](setup.md)), then the
1414
`Napi::Error` class extends `std::exception` and enables integrated
1515
error-handling for C++ exceptions and JavaScript exceptions.
1616

17-
Note, that due to limitations of the N-API, if one attempt to cast the error object thrown as a primitive, an
18-
wrapped object will be received instead. (With properties ```isWrapObject``` and ```errorVal``` containing the primitive value thrown)
17+
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
18+
will be received instead. (With properties ```4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject``` and ```errorVal``` containing the primitive value thrown)
1919

2020

2121
The following sections explain the approach for each case:

napi-inl.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,10 +2609,12 @@ inline Error::Error(napi_env env, napi_value value) : ObjectReference(env, nullp
26092609
Value::From(env, value));
26102610
NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property");
26112611

2612-
status = napi_set_property(env,
2613-
wrappedErrorObj,
2614-
String::From(env, "isWrapObject"),
2615-
Value::From(env, value));
2612+
status = napi_set_property(
2613+
env,
2614+
wrappedErrorObj,
2615+
String::From(env,
2616+
"4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"),
2617+
Value::From(env, value));
26162618
NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property");
26172619

26182620
status = napi_create_reference(env, wrappedErrorObj, 1, &_ref);
@@ -2636,7 +2638,10 @@ inline Object Error::Value() const {
26362638
// We are checking if the object is wrapped
26372639
bool isWrappedObject = false;
26382640
napi_has_property(
2639-
_env, refValue, String::From(_env, "isWrapObject"), &isWrappedObject);
2641+
_env,
2642+
refValue,
2643+
String::From(_env, "4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"),
2644+
&isWrappedObject);
26402645
// Don't care about status
26412646

26422647
if (isWrappedObject == true) {

0 commit comments

Comments
 (0)