Skip to content

Commit a8e4119

Browse files
committed
Update doc and appending GUID to object property
1 parent 6f3e746 commit a8e4119

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
@@ -2597,10 +2597,12 @@ inline Error::Error(napi_env env, napi_value value) : ObjectReference(env, nullp
25972597
Value::From(env, value));
25982598
NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property");
25992599

2600-
status = napi_set_property(env,
2601-
wrappedErrorObj,
2602-
String::From(env, "isWrapObject"),
2603-
Value::From(env, value));
2600+
status = napi_set_property(
2601+
env,
2602+
wrappedErrorObj,
2603+
String::From(env,
2604+
"4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"),
2605+
Value::From(env, value));
26042606
NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property");
26052607

26062608
status = napi_create_reference(env, wrappedErrorObj, 1, &_ref);
@@ -2624,7 +2626,10 @@ inline Object Error::Value() const {
26242626
// We are checking if the object is wrapped
26252627
bool isWrappedObject = false;
26262628
napi_has_property(
2627-
_env, refValue, String::From(_env, "isWrapObject"), &isWrappedObject);
2629+
_env,
2630+
refValue,
2631+
String::From(_env, "4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"),
2632+
&isWrappedObject);
26282633
// Don't care about status
26292634

26302635
if (isWrappedObject == true) {

0 commit comments

Comments
 (0)