Skip to content

Commit 805e614

Browse files
committed
errors: make range mandatory in ERR_OUT_OF_RANGE
So far the range argument was allowed to be undefined. This is not used in the codebase anymore and therefore it is best to make it mandatory for the best user experience. PR-URL: #26924 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent afad3b4 commit 805e614

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/internal/errors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,10 @@ E('ERR_NO_ICU',
995995
E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported', Error);
996996
E('ERR_OUT_OF_RANGE',
997997
(str, range, input, replaceDefaultBoolean = false) => {
998+
assert(range, 'Missing "range" argument');
998999
let msg = replaceDefaultBoolean ? str :
9991000
`The value of "${str}" is out of range.`;
1000-
if (range !== undefined) msg += ` It must be ${range}.`;
1001-
msg += ` Received ${input}`;
1001+
msg += ` It must be ${range}. Received ${input}`;
10021002
return msg;
10031003
}, RangeError);
10041004
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error);

0 commit comments

Comments
 (0)