You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone, just a question regarding the expected behavior of TypeError(napi_env env, napi_value value). According to the docs, it initializes a Napi::TypeError C++ instance from an existing error object, where value is a Napi::Error.
The first problem is that we do not have a cast operator overload that converts a Napi::Error object to a napi_value , so we can't call this ctor with a Napi::Error object directly.
Second of all, my assumption was this ctor accepts an error object and creates a JS TypeError in V8 and a C++ stack object. However, it looks like we simply call the Error ctor with the napi_value. For example, If we give the ctor a napi_value passed from JS, where the napi_value is a RangeError, the resulting Napi::TypedError, when ThrowAsJavaScript, will yield an RangeError still.
So my question is, what is the correct interpretation of this particular API, and what should we do to tweak the implementation to comply with that spec? Thank you!
The text was updated successfully, but these errors were encountered:
the purpose of which is to wrap a value coming in from C. You can wrap any JS value using any of our classes, without validation.
In the next major version, we may wanna
add a ::Wrap(napi_env env, napi_value value) static method to these classes, which performs validation, rejecting, for each class, a napi_value that does not have the corresponding JS type, and
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
Hello everyone, just a question regarding the expected behavior of
TypeError(napi_env env, napi_value value)
. According to the docs, it initializes aNapi::TypeError
C++ instance from an existing error object, wherevalue
is aNapi::Error
.The first problem is that we do not have a cast operator overload that converts a
Napi::Error
object to anapi_value
, so we can't call this ctor with aNapi::Error
object directly.Second of all, my assumption was this ctor accepts an error object and creates a JS
TypeError
in V8 and a C++ stack object. However, it looks like we simply call theError
ctor with thenapi_value
. For example, If we give the ctor anapi_value
passed from JS, where thenapi_value
is aRangeError
, the resultingNapi::TypedError
, whenThrowAsJavaScript
, will yield an RangeError still.So my question is, what is the correct interpretation of this particular API, and what should we do to tweak the implementation to comply with that spec? Thank you!
The text was updated successfully, but these errors were encountered: