| 120 | // the callback. |
| 121 | template <typename Callable> |
| 122 | inline 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, |
no test coverage detected