Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors: remove ERR_INVALID_ARRAY_LENGTH #20484

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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];
Expand Down
28 changes: 14 additions & 14 deletions test/parallel/test-process-hrtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}, {
Expand All @@ -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) {
Expand All @@ -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