Skip to content

Commit c756b84

Browse files
BridgeARtargos
authored andcommittedMar 30, 2019
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 <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 682b410 commit c756b84

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
@@ -933,10 +933,10 @@ E('ERR_NO_ICU',
933933
E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported', Error);
934934
E('ERR_OUT_OF_RANGE',
935935
(str, range, input, replaceDefaultBoolean = false) => {
936+
assert(range, 'Missing "range" argument');
936937
let msg = replaceDefaultBoolean ? str :
937938
`The value of "${str}" is out of range.`;
938-
if (range !== undefined) msg += ` It must be ${range}.`;
939-
msg += ` Received ${input}`;
939+
msg += ` It must be ${range}. Received ${input}`;
940940
return msg;
941941
}, RangeError);
942942
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error);

0 commit comments

Comments
 (0)
Please sign in to comment.