diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index 52e2d7f582ea3e..91e0d67ecdad47 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -1530,10 +1530,8 @@ napi_status napi_create_bigint_words(napi_env env, v8::Local context = env->context(); - if (word_count > INT_MAX) { - napi_throw_range_error(env, nullptr, "Maximum BigInt size exceeded"); - return napi_set_last_error(env, napi_pending_exception); - } + RETURN_STATUS_IF_FALSE( + env, word_count <= INT_MAX, napi_invalid_arg); v8::MaybeLocal b = v8::BigInt::NewFromWords( context, sign_bit, word_count, words); diff --git a/test/js-native-api/test_bigint/test.js b/test/js-native-api/test_bigint/test.js index b92c810459321b..85a183171743c7 100644 --- a/test/js-native-api/test_bigint/test.js +++ b/test/js-native-api/test_bigint/test.js @@ -40,6 +40,6 @@ const { }); assert.throws(CreateTooBigBigInt, { - name: 'RangeError', - message: 'Maximum BigInt size exceeded', + name: 'Error', + message: 'Invalid argument', });