Skip to content

Commit c89f0bf

Browse files
committed
Remove un-necessary comment/iostream and updated docs to reflect on limitations with this impl
1 parent ed4d1c5 commit c89f0bf

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

doc/error_handling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ 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)
19+
20+
1721
The following sections explain the approach for each case:
1822

1923
- [Handling Errors With C++ Exceptions](#exceptions)

napi-inl.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,13 +2628,12 @@ inline Object Error::Value() const {
26282628
if (_ref == nullptr) {
26292629
return Object(_env, nullptr);
26302630
}
2631-
// Most likely will mess up thread execution
26322631

26332632
napi_value refValue;
26342633
napi_status status = napi_get_reference_value(_env, _ref, &refValue);
26352634
NAPI_THROW_IF_FAILED(_env, status, Object());
26362635

2637-
// We are wrapping this object
2636+
// We are checking if the object is wrapped
26382637
bool isWrappedObject = false;
26392638
napi_has_property(
26402639
_env, refValue, String::From(_env, "isWrapObject"), &isWrappedObject);
@@ -2650,17 +2649,6 @@ inline Object Error::Value() const {
26502649

26512650
return Object(_env, refValue);
26522651
}
2653-
// template<typename T>
2654-
// inline T Error::Value() const {
2655-
// // if (_ref == nullptr) {
2656-
// // return T(_env, nullptr);
2657-
// // }
2658-
2659-
// // napi_value value;
2660-
// // napi_status status = napi_get_reference_value(_env, _ref, &value);
2661-
// // NAPI_THROW_IF_FAILED(_env, status, T());
2662-
// return nullptr;
2663-
// }
26642652

26652653
inline Error::Error(Error&& other) : ObjectReference(std::move(other)) {
26662654
}

napi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <node_api.h>
55
#include <functional>
66
#include <initializer_list>
7-
#include <iostream>
87
#include <memory>
98
#include <mutex>
109
#include <string>

0 commit comments

Comments
 (0)