Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c8aa08e

Browse filesBrowse files
legendecasMylesBorins
authored andcommitted
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: #31312 Refs: #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>
1 parent e1fd6ae commit c8aa08e
Copy full SHA for c8aa08e

File tree

Expand file treeCollapse file tree

2 files changed

+4
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-6
lines changed
Open diff view settings
Collapse file

‎src/js_native_api_v8.cc‎

Copy file name to clipboardExpand all lines: src/js_native_api_v8.cc
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,10 +1596,8 @@ napi_status napi_create_bigint_words(napi_env env,
15961596

15971597
v8::Local<v8::Context> context = env->context();
15981598

1599-
if (word_count > INT_MAX) {
1600-
napi_throw_range_error(env, nullptr, "Maximum BigInt size exceeded");
1601-
return napi_set_last_error(env, napi_pending_exception);
1602-
}
1599+
RETURN_STATUS_IF_FALSE(
1600+
env, word_count <= INT_MAX, napi_invalid_arg);
16031601

16041602
v8::MaybeLocal<v8::BigInt> b = v8::BigInt::NewFromWords(
16051603
context, sign_bit, word_count, words);
Collapse file

‎test/js-native-api/test_bigint/test.js‎

Copy file name to clipboardExpand all lines: test/js-native-api/test_bigint/test.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ const {
4040
});
4141

4242
assert.throws(CreateTooBigBigInt, {
43-
name: 'RangeError',
44-
message: 'Maximum BigInt size exceeded',
43+
name: 'Error',
44+
message: 'Invalid argument',
4545
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.