node/test/js-native-api/test_object/test_exceptions.js
Chengzhong Wu 52fcf14258 node-api: return napi_exception_pending on proxy handlers
Accessing JS objects can be trapped with proxy handlers. These
handlers can throw when no node-api errors occur. In such cases,
`napi_pending_exception` should be returned.

PR-URL: https://github.com/nodejs/node/pull/48607
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2023-10-23 18:17:49 -04:00

19 lines
575 B
JavaScript

'use strict';
const common = require('../../common');
// Test
const { testExceptions } = require(`./build/${common.buildType}/test_exceptions`);
function throws() {
throw new Error('foobar');
}
testExceptions(new Proxy({}, {
get: common.mustCallAtLeast(throws, 1),
getOwnPropertyDescriptor: common.mustCallAtLeast(throws, 1),
defineProperty: common.mustCallAtLeast(throws, 1),
deleteProperty: common.mustCallAtLeast(throws, 1),
has: common.mustCallAtLeast(throws, 1),
set: common.mustCallAtLeast(throws, 1),
ownKeys: common.mustCallAtLeast(throws, 1),
}));