MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / WrapVoidCallback

Function WrapVoidCallback

napi-inl.h:122–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120// the callback.
121template <typename Callable>
122inline void WrapVoidCallback(Callable callback) {
123#ifdef NODE_ADDON_API_CPP_EXCEPTIONS
124 try {
125 callback();
126 } catch (const Error& e) {
127 e.ThrowAsJavaScriptException();
128 }
129#else // NAPI_CPP_EXCEPTIONS
130 // When C++ exceptions are disabled, errors are immediately thrown as JS
131 // exceptions, so there is no need to catch and rethrow them here.
132 callback();
133#endif // NAPI_CPP_EXCEPTIONS
134}
135
136// For use in JS to C++ void callback wrappers to catch _any_ thrown exception
137// and rethrow them as JavaScript exceptions before returning from the callback,

Callers 7

WrapperFunction · 0.85
WrapperWithHintFunction · 0.85
WrapperGCWithoutDataFunction · 0.85
WrapperGCFunction · 0.85
WrapperGCWithHintFunction · 0.85
CallJsWrapperFunction · 0.85
CallJSMethod · 0.85

Calls 2

callbackFunction · 0.85

Tested by

no test coverage detected