Skip to content

Commit c0b2584

Browse files
committed
Update doc and appending GUID to object property
1 parent 7382f64 commit c0b2584

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/error_handling.md

+2-2
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

+10-5
Original file line numberDiff line numberDiff line change
@@ -2512,10 +2512,12 @@ inline Error::Error(napi_env env, napi_value value) : ObjectReference(env, nullp
25122512
Value::From(env, value));
25132513
NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property");
25142514

2515-
status = napi_set_property(env,
2516-
wrappedErrorObj,
2517-
String::From(env, "isWrapObject"),
2518-
Value::From(env, value));
2515+
status = napi_set_property(
2516+
env,
2517+
wrappedErrorObj,
2518+
String::From(env,
2519+
"4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"),
2520+
Value::From(env, value));
25192521
NAPI_FATAL_IF_FAILED(status, "Error::Error", "napi_set_property");
25202522

25212523
status = napi_create_reference(env, wrappedErrorObj, 1, &_ref);
@@ -2539,7 +2541,10 @@ inline Object Error::Value() const {
25392541
// We are checking if the object is wrapped
25402542
bool isWrappedObject = false;
25412543
napi_has_property(
2542-
_env, refValue, String::From(_env, "isWrapObject"), &isWrappedObject);
2544+
_env,
2545+
refValue,
2546+
String::From(_env, "4b3d96fd-fb87-4951-a979-eb4f9d2f2ce9-isWrapObject"),
2547+
&isWrappedObject);
25432548
// Don't care about status
25442549

25452550
if (isWrappedObject == true) {

0 commit comments

Comments
 (0)