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: https://github.com/nodejs/node/pull/26924
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Ruben Bridgewater 2019-03-26 15:23:27 +01:00
parent afad3b443e
commit 805e614ba7
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -995,10 +995,10 @@ E('ERR_NO_ICU',
E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported', Error);
E('ERR_OUT_OF_RANGE',
(str, range, input, replaceDefaultBoolean = false) => {
assert(range, 'Missing "range" argument');
let msg = replaceDefaultBoolean ? str :
`The value of "${str}" is out of range.`;
if (range !== undefined) msg += ` It must be ${range}.`;
msg += ` Received ${input}`;
msg += ` It must be ${range}. Received ${input}`;
return msg;
}, RangeError);
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error);