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!
Hello everyone, just a question regarding the expected behavior of
TypeError(napi_env env, napi_value value). According to the docs, it initializes aNapi::TypeErrorC++ instance from an existing error object, wherevalueis aNapi::Error.The first problem is that we do not have a cast operator overload that converts a
Napi::Errorobject to anapi_value, so we can't call this ctor with aNapi::Errorobject directly.Second of all, my assumption was this ctor accepts an error object and creates a JS
TypeErrorin V8 and a C++ stack object. However, it looks like we simply call theErrorctor with thenapi_value. For example, If we give the ctor anapi_valuepassed from JS, where thenapi_valueis 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!