errors: remove ERR_INVALID_ARRAY_LENGTH
This error code is obsolete, since the error message from ERR_OUT_OF_RANGE is more precise. It was only used a single time, so I went ahead and replced this. PR-URL: https://github.com/nodejs/node/pull/20484 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
28a54cb83a
commit
186857f15c
@ -1078,11 +1078,6 @@ An argument of the wrong type was passed to a Node.js API.
|
||||
|
||||
An invalid or unsupported value was passed for a given argument.
|
||||
|
||||
<a id="ERR_INVALID_ARRAY_LENGTH"></a>
|
||||
### ERR_INVALID_ARRAY_LENGTH
|
||||
|
||||
An array was not of the expected length or in a valid range.
|
||||
|
||||
<a id="ERR_INVALID_ASYNC_ID"></a>
|
||||
### ERR_INVALID_ASYNC_ID
|
||||
|
||||
|
@ -865,10 +865,6 @@ E('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => {
|
||||
}
|
||||
return `The argument '${name}' ${reason}. Received ${inspected}`;
|
||||
}, TypeError, RangeError);
|
||||
E('ERR_INVALID_ARRAY_LENGTH',
|
||||
(name, len, actual) => {
|
||||
return `The array "${name}" (length ${actual}) must be of length ${len}.`;
|
||||
}, TypeError);
|
||||
E('ERR_INVALID_ASYNC_ID', 'Invalid %s value: %s', RangeError);
|
||||
E('ERR_INVALID_BUFFER_SIZE',
|
||||
'Buffer size must be a multiple of %s', RangeError);
|
||||
|
@ -6,8 +6,8 @@ const {
|
||||
ERR_ASSERTION,
|
||||
ERR_CPU_USAGE,
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_INVALID_ARRAY_LENGTH,
|
||||
ERR_INVALID_OPT_VALUE,
|
||||
ERR_OUT_OF_RANGE,
|
||||
ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET,
|
||||
ERR_UNKNOWN_SIGNAL
|
||||
}
|
||||
@ -108,7 +108,7 @@ function setup_hrtime() {
|
||||
throw new ERR_INVALID_ARG_TYPE('time', 'Array', time);
|
||||
}
|
||||
if (time.length !== 2) {
|
||||
throw new ERR_INVALID_ARRAY_LENGTH('time', 2, time.length);
|
||||
throw new ERR_OUT_OF_RANGE('time', 2, time.length);
|
||||
}
|
||||
|
||||
const sec = (hrValues[0] * 0x100000000 + hrValues[1]) - time[0];
|
||||
|
@ -23,16 +23,16 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// the default behavior, return an Array "tuple" of numbers
|
||||
// The default behavior, return an Array "tuple" of numbers
|
||||
const tuple = process.hrtime();
|
||||
|
||||
// validate the default behavior
|
||||
// Validate the default behavior
|
||||
validateTuple(tuple);
|
||||
|
||||
// validate that passing an existing tuple returns another valid tuple
|
||||
// Validate that passing an existing tuple returns another valid tuple
|
||||
validateTuple(process.hrtime(tuple));
|
||||
|
||||
// test that only an Array may be passed to process.hrtime()
|
||||
// Test that only an Array may be passed to process.hrtime()
|
||||
common.expectsError(() => {
|
||||
process.hrtime(1);
|
||||
}, {
|
||||
@ -43,23 +43,23 @@ common.expectsError(() => {
|
||||
common.expectsError(() => {
|
||||
process.hrtime([]);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||
type: TypeError,
|
||||
message: 'The array "time" (length 0) must be of length 2.'
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
type: RangeError,
|
||||
message: 'The value of "time" is out of range. It must be 2. Received 0'
|
||||
});
|
||||
common.expectsError(() => {
|
||||
process.hrtime([1]);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||
type: TypeError,
|
||||
message: 'The array "time" (length 1) must be of length 2.'
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
type: RangeError,
|
||||
message: 'The value of "time" is out of range. It must be 2. Received 1'
|
||||
});
|
||||
common.expectsError(() => {
|
||||
process.hrtime([1, 2, 3]);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||
type: TypeError,
|
||||
message: 'The array "time" (length 3) must be of length 2.'
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
type: RangeError,
|
||||
message: 'The value of "time" is out of range. It must be 2. Received 3'
|
||||
});
|
||||
|
||||
function validateTuple(tuple) {
|
||||
@ -70,4 +70,4 @@ function validateTuple(tuple) {
|
||||
}
|
||||
|
||||
const diff = process.hrtime([0, 1e9 - 1]);
|
||||
assert(diff[1] >= 0); // https://github.com/nodejs/node/issues/4751
|
||||
assert(diff[1] >= 0); // https://github.com/nodejs/node/issues/4751
|
||||
|
Loading…
x
Reference in New Issue
Block a user