From c756b8444705c9a7c02ec79463ae9ba5fc135297 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 26 Mar 2019 15:23:27 +0100 Subject: [PATCH] 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 Reviewed-By: Yongsheng Zhang Reviewed-By: Ben Noordhuis --- lib/internal/errors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 3e1921c01340d4..6791deffbdfa26 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -933,10 +933,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);