Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a class that extends ObjectWrap. Here it's declaration.
class NodeOSUserRegistrationMsg: public Napi::ObjectWrap<NodeOSUserRegistrationMsg> { public: static std::string innerTypeName; static Napi::FunctionReference constructor; static void Init(Napi::Env env, Napi::Object exports); FOSUserRegistrationMsg* GetInternalInstance(); NodeOSUserRegistrationMsg(const Napi::CallbackInfo& info); ~NodeOSUserRegistrationMsg(); Napi::Value GetClientAppToken(const Napi::CallbackInfo& info); Napi::Value GetOsUserSid(const Napi::CallbackInfo& info); void SetClientAppToken(const Napi::CallbackInfo& info, const Napi::Value& value); void SetOsUserSid(const Napi::CallbackInfo& info, const Napi::Value& value); private: FOSUserRegistrationMsg* implementation; };
I want to validate the constructor arguments. In the following way.
NodeOSUserRegistrationMsg::NodeOSUserRegistrationMsg(const Napi::CallbackInfo& info): Napi::ObjectWrap<NodeOSUserRegistrationMsg>(info) { if (info.Length() == 1 & info[0].IsExternal()) { this->implementation = info[0].As<Napi::External<FOSUserRegistrationMsg>>().Data(); } else if (info.Length() == 0) { this->implementation = new FOSUserRegistrationMsg(); } else { Napi::TypeError::New(info.Env(), "Unxpected constructor parameters!").ThrowAsJavaScriptException(); } }
The problem is that Napi does not raise this exception to a JS level. In the same time after the validation info.Env().GetAndClearPendingException() returns my error.
info.Env().GetAndClearPendingException()
The text was updated successfully, but these errors were encountered:
Which version of node-addon-api are you using. There were some fixes that went in in later versions to try to address some issues in this area.
Sorry, something went wrong.
Second question do you have C++ exceptions enabled or not?
No branches or pull requests
I have a class that extends ObjectWrap. Here it's declaration.
I want to validate the constructor arguments. In the following way.
The problem is that Napi does not raise this exception to a JS level.
In the same time after the validation
info.Env().GetAndClearPendingException()returns my error.The text was updated successfully, but these errors were encountered: