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

Function canThrow

test/error_handling_for_primitives.js:9–19  ·  view source on GitHub ↗
(binding, errorMessage, errorType)

Source from the content-addressed store, hash-verified

7});
8
9function canThrow (binding, errorMessage, errorType) {
10 try {
11 binding.errorHandlingPrim(() => {
12 throw errorMessage;
13 });
14 } catch (e) {
15 // eslint-disable-next-line valid-typeof
16 assert(typeof e === errorType);
17 assert(e === errorMessage);
18 }
19}
20
21function test (binding) {
22 canThrow(binding, '404 server not found!', 'string');

Callers 1

testFunction · 0.85

Calls

no outgoing calls

Tested by 1

testFunction · 0.68