MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / ConstructorExceptionTest

Class ConstructorExceptionTest

test/objectwrap_constructor_exception.cc:3–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include <napi.h>
2
3class ConstructorExceptionTest
4 : public Napi::ObjectWrap<ConstructorExceptionTest> {
5 public:
6 ConstructorExceptionTest(const Napi::CallbackInfo& info)
7 : Napi::ObjectWrap<ConstructorExceptionTest>(info) {
8 Napi::Error error = Napi::Error::New(info.Env(), "an exception");
9#ifdef NAPI_DISABLE_CPP_EXCEPTIONS
10 error.ThrowAsJavaScriptException();
11#else
12 throw error;
13#endif // NAPI_DISABLE_CPP_EXCEPTIONS
14 }
15
16 static void Initialize(Napi::Env env, Napi::Object exports) {
17 const char* name = "ConstructorExceptionTest";
18 exports.Set(name, DefineClass(env, name, {}));
19 }
20};
21
22Napi::Object InitObjectWrapConstructorException(Napi::Env env) {
23 Napi::Object exports = Napi::Object::New(env);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected