GeezerVison is showing github.com — n-api: return napi_invalid_arg on napi_create_bigint_words · nodejs/node@c8aa08e
File tree
Expand file treeCollapse file tree
Open diff view settings
test/js-native-api/test_bigint
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/js_native_api_v8.cc +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1596,10 +1596,8 @@ napi_status napi_create_bigint_words(napi_env env, |
1596 | 1596 |
|
1597 | 1597 | v8::Local<v8::Context> context = env->context(); |
1598 | 1598 |
|
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); |
1603 | 1601 |
|
1604 | 1602 | v8::MaybeLocal<v8::BigInt> b = v8::BigInt::NewFromWords( |
1605 | 1603 | context, sign_bit, word_count, words); |
|
Collapse file
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 number | Diff line number | Diff line change |
|---|
@@ -40,6 +40,6 @@ const { |
40 | 40 | }); |
41 | 41 |
|
42 | 42 | assert.throws(CreateTooBigBigInt, { |
43 | | - name: 'RangeError', |
44 | | - message: 'Maximum BigInt size exceeded', |
| 43 | + name: 'Error', |
| 44 | + message: 'Invalid argument', |
45 | 45 | }); |