lib: combine similar error codes

There two similar error codes in lib: "ERR_VALUE_OUT_OF_RANGE"
and "ERR_OUT_OF_RANGE". This change is to reduce them into
"ERR_VALUE_OUT_OF_RANGE"

Fixes: https://github.com/nodejs/node/issues/17603

PR-URL: https://github.com/nodejs/node/pull/17648
Fixes: https://github.com/nodejs/node/issues/17603
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Weijia Wang committed 2017-12-24 14:09:29 +08:00
1 parent 4d74b52979
commit d022cb1bdd
17 files changed
+70 -42

No files matched your search

@@ -15,7 +15,7 @@ if (common.isWindows) {
}
const invalidRangeError =
common.expectsError({ code: 'ERR_VALUE_OUT_OF_RANGE', type: RangeError }, 20);
common.expectsError({ code: 'ERR_OUT_OF_RANGE', type: RangeError }, 20);
function pass(option, value) {
// Run the command with the specified option. Since it's not a real command,
+3 -2
View File
@@ -70,7 +70,8 @@ common.expectsError(
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "iterations" argument is out of range'
message: 'The value of "iterations" is out of range. ' +
'It must be a non-negative number. Received -1'
}
);
@@ -93,7 +94,7 @@ common.expectsError(
}, {
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "keylen" argument is out of range'
message: 'The value of "keylen" is out of range.'
});
});
+8 -8
View File
@@ -291,7 +291,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "offset" argument is out of range'
message: 'The value of "offset" is out of range.'
}
);
@@ -300,7 +300,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "offset" argument is out of range'
message: 'The value of "offset" is out of range.'
}
);
@@ -309,7 +309,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "offset" argument is out of range'
message: 'The value of "offset" is out of range.'
}
);
@@ -318,7 +318,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "offset" argument is out of range'
message: 'The value of "offset" is out of range.'
}
);
@@ -421,7 +421,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "size" argument is out of range'
message: 'The value of "size" is out of range.'
}
);
@@ -430,7 +430,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "size" argument is out of range'
message: 'The value of "size" is out of range.'
}
);
@@ -439,7 +439,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "size" argument is out of range'
message: 'The value of "size" is out of range.'
}
);
@@ -448,7 +448,7 @@ process.setMaxListeners(256);
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The "size" argument is out of range'
message: 'The value of "size" is out of range.'
}
);
@@ -36,8 +36,9 @@ for (const obj of throwsObjs) {
() => e.setMaxListeners(obj),
{
code: 'ERR_OUT_OF_RANGE',
type: TypeError,
message: 'The "n" argument is out of range'
type: RangeError,
message: 'The value of "n" is out of range. ' +
`It must be a non-negative number. Received ${obj}`
}
);
@@ -45,8 +46,9 @@ for (const obj of throwsObjs) {
() => events.defaultMaxListeners = obj,
{
code: 'ERR_OUT_OF_RANGE',
type: TypeError,
message: 'The "defaultMaxListeners" argument is out of range'
type: RangeError,
message: 'The value of "defaultMaxListeners" is out of range. ' +
`It must be a non-negative number. Received ${obj}`
}
);
}
+3 -2
View File
@@ -180,8 +180,9 @@ const run_test_4 = common.mustCall(function() {
fs.createWriteStream(filepath, { start: -5, flags: 'r+' });
};
const err = {
code: 'ERR_VALUE_OUT_OF_RANGE',
message: 'The value of "start" must be >= 0. Received "{start: -5}"',
code: 'ERR_OUT_OF_RANGE',
message: 'The value of "start" is out of range. ' +
'It must be >= 0. Received {start: -5}',
type: RangeError
};
common.expectsError(block, err);
+3 -2
View File
@@ -110,14 +110,15 @@ const rangeFile = fixtures.path('x.txt');
{
const message =
'The value of "start" must be <= "end". Received "{start: 10, end: 2}"';
'The value of "start" is out of range. It must be <= "end". ' +
'Received {start: 10, end: 2}';
common.expectsError(
() => {
fs.createReadStream(rangeFile, Object.create({ start: 10, end: 2 }));
},
{
code: 'ERR_VALUE_OUT_OF_RANGE',
code: 'ERR_OUT_OF_RANGE',
message,
type: RangeError
});
+3 -3
View File
@@ -145,9 +145,9 @@ common.expectsError(
fs.createReadStream(rangeFile, { start: 10, end: 2 });
},
{
code: 'ERR_VALUE_OUT_OF_RANGE',
message:
'The value of "start" must be <= "end". Received "{start: 10, end: 2}"',
code: 'ERR_OUT_OF_RANGE',
message: 'The value of "start" is out of range. It must be <= "end". ' +
'Received {start: 10, end: 2}',
type: RangeError
});
+12 -2
View File
@@ -281,8 +281,18 @@ assert.strictEqual(
);
assert.strictEqual(
errors.message('ERR_VALUE_OUT_OF_RANGE', ['A', 'some values', 'B']),
'The value of "A" must be some values. Received "B"'
errors.message('ERR_OUT_OF_RANGE', ['A']),
'The value of "A" is out of range.'
);
assert.strictEqual(
errors.message('ERR_OUT_OF_RANGE', ['A', 'some values']),
'The value of "A" is out of range. It must be some values.'
);
assert.strictEqual(
errors.message('ERR_OUT_OF_RANGE', ['A', 'some values', 'B']),
'The value of "A" is out of range. It must be some values. Received B'
);
assert.strictEqual(
@@ -27,10 +27,11 @@ const timers = require('timers');
common.expectsError(
() => timers.enroll({}, val),
{
code: 'ERR_VALUE_OUT_OF_RANGE',
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The value of "msecs" must be a non-negative ' +
`finite number. Received "${val}"`
message: 'The value of "msecs" is out of range. ' +
'It must be a non-negative finite number. ' +
`Received ${val}`
}
);
});