mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
n-api: return napi_invalid_arg on napi_create_bigint_words
N-API statuses shall be preferred over throwing JavaScript Errors on checks occurred in N-APIs. PR-URL: https://github.com/nodejs/node/pull/31312 Refs: https://github.com/nodejs/node/issues/29849 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
1 parent
52a4a44b76
commit
3a84634cc1
2 files changed
+4
-6
No files matched your search
@@ -1530,10 +1530,8 @@ napi_status napi_create_bigint_words(napi_env env,
|
||||
|
||||
v8::Local<v8::Context> 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<v8::BigInt> b = v8::BigInt::NewFromWords(
|
||||
context, sign_bit, word_count, words);
|
||||
|
||||
@@ -40,6 +40,6 @@ const {
|
||||
});
|
||||
|
||||
assert.throws(CreateTooBigBigInt, {
|
||||
name: 'RangeError',
|
||||
message: 'Maximum BigInt size exceeded',
|
||||
name: 'Error',
|
||||
message: 'Invalid argument',
|
||||
});
|
||||
Reference in new issue
Block a user