process: improve hrtime() error message
Change error message from the form this format: The "time" array must have a length of 2. Received length 0 ...to this format: The array "time" (length 0) must be of length 2. PR-URL: https://github.com/nodejs/node/pull/14324 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
parent
7fdcb68dc3
commit
43e105f645
@ -114,10 +114,9 @@ E('ERR_HTTP_TRAILER_INVALID',
|
|||||||
E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range');
|
E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range');
|
||||||
E('ERR_INVALID_ARG_TYPE', invalidArgType);
|
E('ERR_INVALID_ARG_TYPE', invalidArgType);
|
||||||
E('ERR_INVALID_ARRAY_LENGTH',
|
E('ERR_INVALID_ARRAY_LENGTH',
|
||||||
(name, length, actual) => {
|
(name, len, actual) => {
|
||||||
assert.strictEqual(typeof actual, 'number');
|
assert.strictEqual(typeof actual, 'number');
|
||||||
return `The "${name}" array must have a length of ${
|
return `The array "${name}" (length ${actual}) must be of length ${len}.`;
|
||||||
length}. Received length ${actual}`;
|
|
||||||
});
|
});
|
||||||
E('ERR_INVALID_BUFFER_SIZE', 'Buffer size must be a multiple of %s');
|
E('ERR_INVALID_BUFFER_SIZE', 'Buffer size must be a multiple of %s');
|
||||||
E('ERR_INVALID_CALLBACK', 'Callback must be a function');
|
E('ERR_INVALID_CALLBACK', 'Callback must be a function');
|
||||||
|
@ -45,21 +45,21 @@ assert.throws(() => {
|
|||||||
}, common.expectsError({
|
}, common.expectsError({
|
||||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "time" array must have a length of 2. Received length 0'
|
message: 'The array "time" (length 0) must be of length 2.'
|
||||||
}));
|
}));
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
process.hrtime([1]);
|
process.hrtime([1]);
|
||||||
}, common.expectsError({
|
}, common.expectsError({
|
||||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "time" array must have a length of 2. Received length 1'
|
message: 'The array "time" (length 1) must be of length 2.'
|
||||||
}));
|
}));
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
process.hrtime([1, 2, 3]);
|
process.hrtime([1, 2, 3]);
|
||||||
}, common.expectsError({
|
}, common.expectsError({
|
||||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "time" array must have a length of 2. Received length 3'
|
message: 'The array "time" (length 3) must be of length 2.'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function validateTuple(tuple) {
|
function validateTuple(tuple) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user