errors: update error name

This updates all Node.js errors by removing the `code` being part
of the `name` property. Instead, the name is just changed once on
instantiation, the stack is accessed to create the stack as expected
and then the `name` property is set back to it's original form.

PR-URL: https://github.com/nodejs/node/pull/26738
Fixes: https://github.com/nodejs/node/issues/26669
Fixes: https://github.com/nodejs/node/issues/20253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
Ruben Bridgewater 2019-03-16 12:09:14 +01:00
parent c757cb1b98
commit 1ed3c54ecb
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
71 changed files with 283 additions and 284 deletions

View File

@ -388,12 +388,25 @@ class AssertionError extends Error {
} }
this.generatedMessage = !message; this.generatedMessage = !message;
this.name = 'AssertionError [ERR_ASSERTION]'; Object.defineProperty(this, 'name', {
value: 'AssertionError [ERR_ASSERTION]',
enumerable: false,
writable: true,
configurable: true
});
this.code = 'ERR_ASSERTION'; this.code = 'ERR_ASSERTION';
this.actual = actual; this.actual = actual;
this.expected = expected; this.expected = expected;
this.operator = operator; this.operator = operator;
Error.captureStackTrace(this, stackStartFn); Error.captureStackTrace(this, stackStartFn);
// Create error message including the error code in the name.
this.stack;
// Reset the name.
this.name = 'AssertionError';
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
} }
[inspect.custom](recurseTimes, ctx) { [inspect.custom](recurseTimes, ctx) {

View File

@ -18,6 +18,8 @@ const codes = {};
const { kMaxLength } = internalBinding('buffer'); const { kMaxLength } = internalBinding('buffer');
const { defineProperty } = Object; const { defineProperty } = Object;
let useOriginalName = false;
// Lazily loaded // Lazily loaded
let util; let util;
let assert; let assert;
@ -74,19 +76,7 @@ class SystemError extends Error {
value: key, value: key,
writable: true writable: true
}); });
} addCodeToName(this, 'SystemError', key);
get name() {
return `SystemError [${this[kCode]}]`;
}
set name(value) {
defineProperty(this, 'name', {
configurable: true,
enumerable: true,
value,
writable: true
});
} }
get code() { get code() {
@ -141,6 +131,10 @@ class SystemError extends Error {
this[kInfo].dest = val ? this[kInfo].dest = val ?
lazyBuffer().from(val.toString()) : undefined; lazyBuffer().from(val.toString()) : undefined;
} }
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
} }
function makeSystemErrorWithCode(key) { function makeSystemErrorWithCode(key) {
@ -151,8 +145,6 @@ function makeSystemErrorWithCode(key) {
}; };
} }
let useOriginalName = false;
function makeNodeErrorWithCode(Base, key) { function makeNodeErrorWithCode(Base, key) {
return class NodeError extends Base { return class NodeError extends Base {
constructor(...args) { constructor(...args) {
@ -164,22 +156,7 @@ function makeNodeErrorWithCode(Base, key) {
writable: true, writable: true,
configurable: true configurable: true
}); });
} addCodeToName(this, super.name, key);
get name() {
if (useOriginalName) {
return super.name;
}
return `${super.name} [${key}]`;
}
set name(value) {
defineProperty(this, 'name', {
configurable: true,
enumerable: true,
value,
writable: true
});
} }
get code() { get code() {
@ -194,9 +171,35 @@ function makeNodeErrorWithCode(Base, key) {
writable: true writable: true
}); });
} }
toString() {
return `${this.name} [${key}]: ${this.message}`;
}
}; };
} }
function addCodeToName(err, name, code) {
if (useOriginalName) {
return;
}
// Add the error code to the name to include it in the stack trace.
err.name = `${name} [${code}]`;
// Access the stack to generate the error message including the error code
// from the name.
err.stack;
// Reset the name to the actual name.
if (name === 'SystemError') {
defineProperty(err, 'name', {
value: name,
enumerable: false,
writable: true,
configurable: true
});
} else {
delete err.name;
}
}
// Utility function for registering the error codes. Only used here. Exported // Utility function for registering the error codes. Only used here. Exported
// *only* to allow for testing. // *only* to allow for testing.
function E(sym, val, def, ...otherClasses) { function E(sym, val, def, ...otherClasses) {

View File

@ -498,6 +498,12 @@ class NghttpError extends Error {
this.code = 'ERR_HTTP2_ERROR'; this.code = 'ERR_HTTP2_ERROR';
this.name = 'Error [ERR_HTTP2_ERROR]'; this.name = 'Error [ERR_HTTP2_ERROR]';
this.errno = ret; this.errno = ret;
this.stack;
delete this.name;
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
} }
} }

View File

@ -13,7 +13,7 @@ const promises = [];
const rejectingFn = async () => assert.fail(); const rejectingFn = async () => assert.fail();
const errObj = { const errObj = {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'Failed' message: 'Failed'
}; };
// `assert.rejects` accepts a function or a promise as first argument. // `assert.rejects` accepts a function or a promise as first argument.
@ -38,7 +38,7 @@ const promises = [];
promise = assert.rejects(() => {}, common.mustNotCall()); promise = assert.rejects(() => {}, common.mustNotCall());
promises.push(assert.rejects(promise, { promises.push(assert.rejects(promise, {
name: 'TypeError [ERR_INVALID_RETURN_VALUE]', name: 'TypeError',
code: 'ERR_INVALID_RETURN_VALUE', code: 'ERR_INVALID_RETURN_VALUE',
message: 'Expected instance of Promise to be returned ' + message: 'Expected instance of Promise to be returned ' +
'from the "promiseFn" function but got type undefined.' 'from the "promiseFn" function but got type undefined.'
@ -75,7 +75,7 @@ promises.push(assert.rejects(
message: 'Expected instance of Promise to be returned ' + message: 'Expected instance of Promise to be returned ' +
'from the "promiseFn" function but got instance of Map.', 'from the "promiseFn" function but got instance of Map.',
code: 'ERR_INVALID_RETURN_VALUE', code: 'ERR_INVALID_RETURN_VALUE',
name: 'TypeError [ERR_INVALID_RETURN_VALUE]' name: 'TypeError'
})); }));
promises.push(assert.doesNotReject(async () => {})); promises.push(assert.doesNotReject(async () => {}));
promises.push(assert.doesNotReject(Promise.resolve())); promises.push(assert.doesNotReject(Promise.resolve()));

View File

@ -778,7 +778,7 @@ assert.throws(
assert.throws( assert.throws(
() => assert.notDeepStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)), () => assert.notDeepStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)),
{ {
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'Expected "actual" not to be strictly deep-equal to: ' + message: 'Expected "actual" not to be strictly deep-equal to: ' +
util.inspect(new Date(2000, 3, 14)) util.inspect(new Date(2000, 3, 14))
} }
@ -790,35 +790,35 @@ assert.throws(
() => assert.deepStrictEqual(/ab/, /a/), () => assert.deepStrictEqual(/ab/, /a/),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /ab/\n- /a/` message: `${defaultMsgStartFull}\n\n+ /ab/\n- /a/`
}); });
assert.throws( assert.throws(
() => assert.deepStrictEqual(/a/g, /a/), () => assert.deepStrictEqual(/a/g, /a/),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /a/g\n- /a/` message: `${defaultMsgStartFull}\n\n+ /a/g\n- /a/`
}); });
assert.throws( assert.throws(
() => assert.deepStrictEqual(/a/i, /a/), () => assert.deepStrictEqual(/a/i, /a/),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /a/i\n- /a/` message: `${defaultMsgStartFull}\n\n+ /a/i\n- /a/`
}); });
assert.throws( assert.throws(
() => assert.deepStrictEqual(/a/m, /a/), () => assert.deepStrictEqual(/a/m, /a/),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /a/m\n- /a/` message: `${defaultMsgStartFull}\n\n+ /a/m\n- /a/`
}); });
assert.throws( assert.throws(
() => assert.deepStrictEqual(/a/igm, /a/im), () => assert.deepStrictEqual(/a/igm, /a/im),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /a/gim\n- /a/im\n ^` message: `${defaultMsgStartFull}\n\n+ /a/gim\n- /a/im\n ^`
}); });
@ -844,14 +844,14 @@ assert.deepStrictEqual({ a: 4, b: '2' }, { a: 4, b: '2' });
assert.throws(() => assert.deepStrictEqual([4], ['4']), assert.throws(() => assert.deepStrictEqual([4], ['4']),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n [\n+ 4\n- '4'\n ]` message: `${defaultMsgStartFull}\n\n [\n+ 4\n- '4'\n ]`
}); });
assert.throws( assert.throws(
() => assert.deepStrictEqual({ a: 4 }, { a: 4, b: true }), () => assert.deepStrictEqual({ a: 4 }, { a: 4, b: true }),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n ` + message: `${defaultMsgStartFull}\n\n ` +
'{\n a: 4,\n- b: true\n }' '{\n a: 4,\n- b: true\n }'
}); });
@ -859,7 +859,7 @@ assert.throws(
() => assert.deepStrictEqual(['a'], { 0: 'a' }), () => assert.deepStrictEqual(['a'], { 0: 'a' }),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n` + message: `${defaultMsgStartFull}\n\n` +
"+ [\n+ 'a'\n+ ]\n- {\n- '0': 'a'\n- }" "+ [\n+ 'a'\n+ ]\n- {\n- '0': 'a'\n- }"
}); });
@ -953,7 +953,7 @@ assert.deepStrictEqual(obj1, obj2);
() => assert.deepStrictEqual(a, b), () => assert.deepStrictEqual(a, b),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: /\.\.\./g message: /\.\.\./g
} }
); );
@ -977,7 +977,7 @@ assert.throws(
() => assert.deepStrictEqual([1, 2, 3], [1, 2]), () => assert.deepStrictEqual([1, 2, 3], [1, 2]),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n` + message: `${defaultMsgStartFull}\n\n` +
' [\n' + ' [\n' +
' 1,\n' + ' 1,\n' +
@ -1063,7 +1063,7 @@ assert.throws(
() => assert.deepStrictEqual(a, b), () => assert.deepStrictEqual(a, b),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n / message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n /
} }
); );

View File

@ -15,7 +15,7 @@ assert.throws(() => {
assert.fail('first', 'second'); assert.fail('first', 'second');
}, { }, {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: '\'first\' != \'second\'', message: '\'first\' != \'second\'',
operator: '!=', operator: '!=',
actual: 'first', actual: 'first',
@ -28,7 +28,7 @@ assert.throws(() => {
assert.fail('ignored', 'ignored', 'another custom message'); assert.fail('ignored', 'ignored', 'another custom message');
}, { }, {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'another custom message', message: 'another custom message',
operator: 'fail', operator: 'fail',
actual: 'ignored', actual: 'ignored',
@ -49,7 +49,7 @@ assert.throws(() => {
assert.fail('first', 'second', undefined, 'operator'); assert.fail('first', 'second', undefined, 'operator');
}, { }, {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: '\'first\' operator \'second\'', message: '\'first\' operator \'second\'',
operator: 'operator', operator: 'operator',
actual: 'first', actual: 'first',

View File

@ -8,7 +8,7 @@ assert.throws(
() => { assert.fail(); }, () => { assert.fail(); },
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'Failed', message: 'Failed',
operator: 'fail', operator: 'fail',
actual: undefined, actual: undefined,
@ -22,7 +22,7 @@ assert.throws(() => {
assert.fail('custom message'); assert.fail('custom message');
}, { }, {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'custom message', message: 'custom message',
operator: 'fail', operator: 'fail',
actual: undefined, actual: undefined,

View File

@ -9,7 +9,7 @@ const { path } = require('../common/fixtures');
assert.throws( assert.throws(
() => require(path('assert-first-line')), () => require(path('assert-first-line')),
{ {
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: "The expression evaluated to a falsy value:\n\n ässört.ok('')\n" message: "The expression evaluated to a falsy value:\n\n ässört.ok('')\n"
} }
); );
@ -17,7 +17,7 @@ assert.throws(
assert.throws( assert.throws(
() => require(path('assert-long-line')), () => require(path('assert-long-line')),
{ {
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: "The expression evaluated to a falsy value:\n\n assert.ok('')\n" message: "The expression evaluated to a falsy value:\n\n assert.ok('')\n"
} }
); );

View File

@ -73,7 +73,7 @@ assert.throws(
() => a.notStrictEqual(2, 2), () => a.notStrictEqual(2, 2),
{ {
message: 'Expected "actual" to be strictly unequal to: 2', message: 'Expected "actual" to be strictly unequal to: 2',
name: 'AssertionError [ERR_ASSERTION]' name: 'AssertionError'
} }
); );
@ -82,7 +82,7 @@ assert.throws(
{ {
message: 'Expected "actual" to be strictly unequal to: ' + message: 'Expected "actual" to be strictly unequal to: ' +
`'${'a '.repeat(30)}'`, `'${'a '.repeat(30)}'`,
name: 'AssertionError [ERR_ASSERTION]' name: 'AssertionError'
} }
); );
@ -141,7 +141,7 @@ assert.throws(() => thrower(TypeError));
assert.throws( assert.throws(
() => a.doesNotThrow(() => thrower(Error), 'user message'), () => a.doesNotThrow(() => thrower(Error), 'user message'),
{ {
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
operator: 'doesNotThrow', operator: 'doesNotThrow',
message: 'Got unwanted exception: user message\n' + message: 'Got unwanted exception: user message\n' +
@ -400,7 +400,7 @@ assert.throws(() => {
() => new assert.AssertionError(input), () => new assert.AssertionError(input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "options" argument must be of type Object. ' + message: 'The "options" argument must be of type Object. ' +
`Received type ${typeof input}` `Received type ${typeof input}`
}); });
@ -411,7 +411,7 @@ assert.throws(
() => assert.strictEqual(new Error('foo'), new Error('foobar')), () => assert.strictEqual(new Error('foo'), new Error('foobar')),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'Expected "actual" to be reference-equal to "expected":\n' + message: 'Expected "actual" to be reference-equal to "expected":\n' +
'+ actual - expected\n\n' + '+ actual - expected\n\n' +
'+ [Error: foo]\n- [Error: foobar]' '+ [Error: foo]\n- [Error: foobar]'
@ -438,7 +438,7 @@ assert.throws(
() => assert(...[]), () => assert(...[]),
{ {
message: 'No value argument passed to `assert.ok()`', message: 'No value argument passed to `assert.ok()`',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
generatedMessage: true generatedMessage: true
} }
); );
@ -446,7 +446,7 @@ assert.throws(
() => a(), () => a(),
{ {
message: 'No value argument passed to `assert.ok()`', message: 'No value argument passed to `assert.ok()`',
name: 'AssertionError [ERR_ASSERTION]' name: 'AssertionError'
} }
); );
@ -886,7 +886,7 @@ common.expectsError(
() => assert.throws(errFn, errObj), () => assert.throws(errFn, errObj),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${start}\n${actExp}\n\n` + message: `${start}\n${actExp}\n\n` +
' Comparison {\n' + ' Comparison {\n' +
' code: 404,\n' + ' code: 404,\n' +
@ -903,7 +903,7 @@ common.expectsError(
() => assert.throws(errFn, errObj), () => assert.throws(errFn, errObj),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: `${start}\n${actExp}\n\n` + message: `${start}\n${actExp}\n\n` +
' Comparison {\n' + ' Comparison {\n' +
'+ code: 404,\n' + '+ code: 404,\n' +
@ -938,7 +938,7 @@ common.expectsError(
assert.throws( assert.throws(
() => assert.throws(() => { throw new TypeError('e'); }, new Error('e')), () => assert.throws(() => { throw new TypeError('e'); }, new Error('e')),
{ {
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
message: `${start}\n${actExp}\n\n` + message: `${start}\n${actExp}\n\n` +
' Comparison {\n' + ' Comparison {\n' +
@ -951,7 +951,7 @@ common.expectsError(
assert.throws( assert.throws(
() => assert.throws(() => { throw new Error('foo'); }, new Error('')), () => assert.throws(() => { throw new Error('foo'); }, new Error('')),
{ {
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
generatedMessage: true, generatedMessage: true,
message: `${start}\n${actExp}\n\n` + message: `${start}\n${actExp}\n\n` +
@ -969,7 +969,7 @@ common.expectsError(
// eslint-disable-next-line no-throw-literal // eslint-disable-next-line no-throw-literal
() => a.doesNotThrow(() => { throw undefined; }), () => a.doesNotThrow(() => { throw undefined; }),
{ {
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
message: 'Got unwanted exception.\nActual message: "undefined"' message: 'Got unwanted exception.\nActual message: "undefined"'
} }
@ -1102,7 +1102,7 @@ assert.throws(
() => assert.strictEqual('test test', 'test foobar'), () => assert.strictEqual('test test', 'test foobar'),
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: strictEqualMessageStart + message: strictEqualMessageStart +
'+ actual - expected\n\n' + '+ actual - expected\n\n' +
"+ 'test test'\n" + "+ 'test test'\n" +
@ -1119,7 +1119,7 @@ assert.throws(
}, },
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'Expected "actual" not to be reference-equal to "expected": {}' message: 'Expected "actual" not to be reference-equal to "expected": {}'
} }
); );
@ -1131,7 +1131,7 @@ assert.throws(
}, },
{ {
code: 'ERR_ASSERTION', code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]', name: 'AssertionError',
message: 'Expected "actual" not to be reference-equal to "expected":\n\n' + message: 'Expected "actual" not to be reference-equal to "expected":\n\n' +
'{\n a: true\n}\n' '{\n a: true\n}\n'
} }

View File

@ -967,12 +967,12 @@ common.expectsError(
}); });
assert.throws(() => Buffer.from(), { assert.throws(() => Buffer.from(), {
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The first argument must be one of type string, Buffer, ' + message: 'The first argument must be one of type string, Buffer, ' +
'ArrayBuffer, Array, or Array-like Object. Received type undefined' 'ArrayBuffer, Array, or Array-like Object. Received type undefined'
}); });
assert.throws(() => Buffer.from(null), { assert.throws(() => Buffer.from(null), {
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The first argument must be one of type string, Buffer, ' + message: 'The first argument must be one of type string, Buffer, ' +
'ArrayBuffer, Array, or Array-like Object. Received type object' 'ArrayBuffer, Array, or Array-like Object. Received type object'
}); });

View File

@ -42,7 +42,7 @@ assert.throws(function() {
Buffer.from(new AB()); Buffer.from(new AB());
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The first argument must be one of type string, Buffer,' + message: 'The first argument must be one of type string, Buffer,' +
' ArrayBuffer, Array, or Array-like Object. Received type object' ' ArrayBuffer, Array, or Array-like Object. Received type object'
}); });
@ -65,12 +65,12 @@ assert.throws(function() {
assert.throws(() => Buffer.from(ab.buffer, 6), { assert.throws(() => Buffer.from(ab.buffer, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: '"offset" is outside of buffer bounds' message: '"offset" is outside of buffer bounds'
}); });
assert.throws(() => Buffer.from(ab.buffer, 3, 6), { assert.throws(() => Buffer.from(ab.buffer, 3, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: '"length" is outside of buffer bounds' message: '"length" is outside of buffer bounds'
}); });
} }
@ -93,12 +93,12 @@ assert.throws(function() {
assert.throws(() => Buffer(ab.buffer, 6), { assert.throws(() => Buffer(ab.buffer, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: '"offset" is outside of buffer bounds' message: '"offset" is outside of buffer bounds'
}); });
assert.throws(() => Buffer(ab.buffer, 3, 6), { assert.throws(() => Buffer(ab.buffer, 3, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: '"length" is outside of buffer bounds' message: '"length" is outside of buffer bounds'
}); });
} }
@ -120,7 +120,7 @@ assert.throws(function() {
Buffer.from(ab, Infinity); Buffer.from(ab, Infinity);
}, { }, {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: '"offset" is outside of buffer bounds' message: '"offset" is outside of buffer bounds'
}); });
} }
@ -142,7 +142,7 @@ assert.throws(function() {
Buffer.from(ab, 0, Infinity); Buffer.from(ab, 0, Infinity);
}, { }, {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: '"length" is outside of buffer bounds' message: '"length" is outside of buffer bounds'
}); });
} }

View File

@ -54,12 +54,12 @@ read(buf, 'readUIntLE', [2, 2], 0xea48);
// Error name and message // Error name and message
const OOR_ERROR = const OOR_ERROR =
{ {
name: 'RangeError [ERR_OUT_OF_RANGE]' name: 'RangeError'
}; };
const OOB_ERROR = const OOB_ERROR =
{ {
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: 'Attempt to write outside buffer bounds' message: 'Attempt to write outside buffer bounds'
}; };

View File

@ -116,7 +116,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
() => buffer[fn](offset), () => buffer[fn](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= 0. Received ${offset}` `It must be >= 0 and <= 0. Received ${offset}`
}); });
@ -126,7 +126,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
() => Buffer.alloc(1)[fn](1), () => Buffer.alloc(1)[fn](1),
{ {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: 'Attempt to write outside buffer bounds' message: 'Attempt to write outside buffer bounds'
}); });
@ -135,7 +135,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
() => buffer[fn](offset), () => buffer[fn](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -79,7 +79,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
() => buffer[fn](offset), () => buffer[fn](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= 0. Received ${offset}` `It must be >= 0 and <= 0. Received ${offset}`
}); });
@ -89,7 +89,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
() => Buffer.alloc(1)[fn](1), () => Buffer.alloc(1)[fn](1),
{ {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: 'Attempt to write outside buffer bounds' message: 'Attempt to write outside buffer bounds'
}); });
@ -98,7 +98,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
() => buffer[fn](offset), () => buffer[fn](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -18,7 +18,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](o), () => buffer[`read${fn}`](o),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
}); });
}); });
@ -27,7 +27,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](offset), () => buffer[`read${fn}`](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]' name: 'RangeError'
}); });
}); });
@ -36,7 +36,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](offset), () => buffer[`read${fn}`](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });
@ -152,7 +152,7 @@ const assert = require('assert');
() => buffer[fn](0, byteLength), () => buffer[fn](0, byteLength),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' + message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}` `It must be an integer. Received ${byteLength}`
}); });
@ -167,7 +167,7 @@ const assert = require('assert');
() => buffer[fn](o, i), () => buffer[fn](o, i),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
}); });
}); });
@ -176,7 +176,7 @@ const assert = require('assert');
() => buffer[fn](offset, i), () => buffer[fn](offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= ${8 - i}. Received ${offset}` `It must be >= 0 and <= ${8 - i}. Received ${offset}`
}); });
@ -187,7 +187,7 @@ const assert = require('assert');
() => buffer[fn](offset, i), () => buffer[fn](offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -18,7 +18,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](o), () => buffer[`read${fn}`](o),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
}); });
}); });
@ -27,7 +27,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](offset), () => buffer[`read${fn}`](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]' name: 'RangeError'
}); });
}); });
@ -36,7 +36,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](offset), () => buffer[`read${fn}`](offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });
@ -120,7 +120,7 @@ const assert = require('assert');
() => buffer[fn](0, byteLength), () => buffer[fn](0, byteLength),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' + message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}` `It must be an integer. Received ${byteLength}`
}); });
@ -135,7 +135,7 @@ const assert = require('assert');
() => buffer[fn](o, i), () => buffer[fn](o, i),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
}); });
}); });
@ -144,7 +144,7 @@ const assert = require('assert');
() => buffer[fn](offset, i), () => buffer[fn](offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= ${8 - i}. Received ${offset}` `It must be >= 0 and <= ${8 - i}. Received ${offset}`
}); });
@ -155,7 +155,7 @@ const assert = require('assert');
() => buffer[fn](offset, i), () => buffer[fn](offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -42,7 +42,7 @@ try {
// Should throw with invalid length type // Should throw with invalid length type
const bufferInvalidTypeMsg = { const bufferInvalidTypeMsg = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: /^The "size" argument must be of type number/, message: /^The "size" argument must be of type number/,
}; };
assert.throws(() => SlowBuffer(), bufferInvalidTypeMsg); assert.throws(() => SlowBuffer(), bufferInvalidTypeMsg);
@ -53,7 +53,7 @@ assert.throws(() => SlowBuffer(true), bufferInvalidTypeMsg);
// Should throw with invalid length value // Should throw with invalid length value
const bufferMaxSizeMsg = { const bufferMaxSizeMsg = {
code: 'ERR_INVALID_OPT_VALUE', code: 'ERR_INVALID_OPT_VALUE',
name: 'RangeError [ERR_INVALID_OPT_VALUE]', name: 'RangeError',
message: /^The value "[^"]*" is invalid for option "size"$/ message: /^The value "[^"]*" is invalid for option "size"$/
}; };
assert.throws(() => SlowBuffer(NaN), bufferMaxSizeMsg); assert.throws(() => SlowBuffer(NaN), bufferMaxSizeMsg);

View File

@ -98,7 +98,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
() => small[fn](11.11, 0), () => small[fn](11.11, 0),
{ {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: 'Attempt to write outside buffer bounds' message: 'Attempt to write outside buffer bounds'
}); });
@ -113,7 +113,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
() => buffer[fn](23, offset), () => buffer[fn](23, offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= 8. Received ${offset}` `It must be >= 0 and <= 8. Received ${offset}`
}); });
@ -124,7 +124,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
() => buffer[fn](42, offset), () => buffer[fn](42, offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -80,7 +80,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
() => small[fn](11.11, 0), () => small[fn](11.11, 0),
{ {
code: 'ERR_BUFFER_OUT_OF_BOUNDS', code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]', name: 'RangeError',
message: 'Attempt to write outside buffer bounds' message: 'Attempt to write outside buffer bounds'
}); });
@ -96,7 +96,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
() => buffer[fn](23, offset), () => buffer[fn](23, offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= 4. Received ${offset}` `It must be >= 0 and <= 4. Received ${offset}`
} }
@ -108,7 +108,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
() => buffer[fn](42, offset), () => buffer[fn](42, offset),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -205,7 +205,7 @@ const errorOutOfBounds = common.expectsError({
() => data[fn](42, 0, byteLength), () => data[fn](42, 0, byteLength),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' + message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}` `It must be an integer. Received ${byteLength}`
}); });
@ -223,7 +223,7 @@ const errorOutOfBounds = common.expectsError({
data[fn](val, 0, i); data[fn](val, 0, i);
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "value" is out of range. ' + message: 'The value of "value" is out of range. ' +
`It must be >= ${min} and <= ${max}. Received ${val}` `It must be >= ${min} and <= ${max}. Received ${val}`
}); });
@ -234,7 +234,7 @@ const errorOutOfBounds = common.expectsError({
() => data[fn](min, o, i), () => data[fn](min, o, i),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
}); });
}); });
@ -243,7 +243,7 @@ const errorOutOfBounds = common.expectsError({
() => data[fn](min, offset, i), () => data[fn](min, offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= ${8 - i}. Received ${offset}` `It must be >= 0 and <= ${8 - i}. Received ${offset}`
}); });
@ -254,7 +254,7 @@ const errorOutOfBounds = common.expectsError({
() => data[fn](max, offset, i), () => data[fn](max, offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -162,7 +162,7 @@ const assert = require('assert');
() => data[fn](42, 0, byteLength), () => data[fn](42, 0, byteLength),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' + message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}` `It must be an integer. Received ${byteLength}`
}); });
@ -176,7 +176,7 @@ const assert = require('assert');
data[fn](val, 0, i); data[fn](val, 0, i);
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "value" is out of range. ' + message: 'The value of "value" is out of range. ' +
`It must be >= 0 and <= ${val - 1}. Received ${val}` `It must be >= 0 and <= ${val - 1}. Received ${val}`
}); });
@ -186,7 +186,7 @@ const assert = require('assert');
() => data[fn](23, o, i), () => data[fn](23, o, i),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
}); });
}); });
@ -195,7 +195,7 @@ const assert = require('assert');
() => data[fn](val - 1, offset, i), () => data[fn](val - 1, offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 and <= ${8 - i}. Received ${offset}` `It must be >= 0 and <= ${8 - i}. Received ${offset}`
}); });
@ -206,7 +206,7 @@ const assert = require('assert');
() => data[fn](val - 1, offset, i), () => data[fn](val - 1, offset, i),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be an integer. Received ${offset}` `It must be an integer. Received ${offset}`
}); });

View File

@ -39,18 +39,18 @@ n.on('message', (m) => {
// https://github.com/joyent/node/issues/2355 - JSON.stringify(undefined) // https://github.com/joyent/node/issues/2355 - JSON.stringify(undefined)
// returns "undefined" but JSON.parse() cannot parse that... // returns "undefined" but JSON.parse() cannot parse that...
assert.throws(() => n.send(undefined), { assert.throws(() => n.send(undefined), {
name: 'TypeError [ERR_MISSING_ARGS]', name: 'TypeError',
message: 'The "message" argument must be specified', message: 'The "message" argument must be specified',
code: 'ERR_MISSING_ARGS' code: 'ERR_MISSING_ARGS'
}); });
assert.throws(() => n.send(), { assert.throws(() => n.send(), {
name: 'TypeError [ERR_MISSING_ARGS]', name: 'TypeError',
message: 'The "message" argument must be specified', message: 'The "message" argument must be specified',
code: 'ERR_MISSING_ARGS' code: 'ERR_MISSING_ARGS'
}); });
assert.throws(() => n.send(Symbol()), { assert.throws(() => n.send(Symbol()), {
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "message" argument must be one of type string,' + message: 'The "message" argument must be one of type string,' +
' object, number, or boolean. Received type symbol', ' object, number, or boolean. Received type symbol',
code: 'ERR_INVALID_ARG_TYPE' code: 'ERR_INVALID_ARG_TYPE'

View File

@ -64,7 +64,7 @@ assert.throws(
() => crypto.pbkdf2('password', 'salt', 1, 20, null), () => crypto.pbkdf2('password', 'salt', 1, 20, null),
{ {
code: 'ERR_INVALID_CALLBACK', code: 'ERR_INVALID_CALLBACK',
name: 'TypeError [ERR_INVALID_CALLBACK]' name: 'TypeError'
} }
); );
@ -72,7 +72,7 @@ assert.throws(
() => crypto.pbkdf2Sync('password', 'salt', -1, 20, 'sha1'), () => crypto.pbkdf2Sync('password', 'salt', -1, 20, 'sha1'),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "iterations" is out of range. ' + message: 'The value of "iterations" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1' 'It must be >= 0 && < 4294967296. Received -1'
} }
@ -84,7 +84,7 @@ assert.throws(
crypto.pbkdf2Sync('password', 'salt', 1, notNumber, 'sha256'); crypto.pbkdf2Sync('password', 'salt', 1, notNumber, 'sha256');
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "keylen" argument must be of type number. ' + message: 'The "keylen" argument must be of type number. ' +
`Received type ${typeof notNumber}` `Received type ${typeof notNumber}`
}); });
@ -97,7 +97,7 @@ assert.throws(
common.mustNotCall()); common.mustNotCall());
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "keylen" is out of range. It ' + message: 'The value of "keylen" is out of range. It ' +
`must be an integer. Received ${input}` `must be an integer. Received ${input}`
}); });
@ -110,7 +110,7 @@ assert.throws(
common.mustNotCall()); common.mustNotCall());
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "keylen" is out of range. It ' + message: 'The value of "keylen" is out of range. It ' +
`must be >= 0 && < 4294967296. Received ${input}` `must be >= 0 && < 4294967296. Received ${input}`
}); });
@ -124,7 +124,7 @@ assert.throws(
() => crypto.pbkdf2('password', 'salt', 8, 8, common.mustNotCall()), () => crypto.pbkdf2('password', 'salt', 8, 8, common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "digest" argument must be one of type string or null. ' + message: 'The "digest" argument must be one of type string or null. ' +
'Received type undefined' 'Received type undefined'
}); });
@ -133,7 +133,7 @@ assert.throws(
() => crypto.pbkdf2Sync('password', 'salt', 8, 8), () => crypto.pbkdf2Sync('password', 'salt', 8, 8),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "digest" argument must be one of type string or null. ' + message: 'The "digest" argument must be one of type string or null. ' +
'Received type undefined' 'Received type undefined'
}); });
@ -145,7 +145,7 @@ assert.throws(
() => crypto.pbkdf2(input, 'salt', 8, 8, 'sha256', common.mustNotCall()), () => crypto.pbkdf2(input, 'salt', 8, 8, 'sha256', common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "password" argument must be one of type string, ${msgPart2}` message: `The "password" argument must be one of type string, ${msgPart2}`
} }
); );
@ -154,7 +154,7 @@ assert.throws(
() => crypto.pbkdf2('pass', input, 8, 8, 'sha256', common.mustNotCall()), () => crypto.pbkdf2('pass', input, 8, 8, 'sha256', common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "salt" argument must be one of type string, ${msgPart2}` message: `The "salt" argument must be one of type string, ${msgPart2}`
} }
); );
@ -163,7 +163,7 @@ assert.throws(
() => crypto.pbkdf2Sync(input, 'salt', 8, 8, 'sha256'), () => crypto.pbkdf2Sync(input, 'salt', 8, 8, 'sha256'),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "password" argument must be one of type string, ${msgPart2}` message: `The "password" argument must be one of type string, ${msgPart2}`
} }
); );
@ -172,7 +172,7 @@ assert.throws(
() => crypto.pbkdf2Sync('pass', input, 8, 8, 'sha256'), () => crypto.pbkdf2Sync('pass', input, 8, 8, 'sha256'),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "salt" argument must be one of type string, ${msgPart2}` message: `The "salt" argument must be one of type string, ${msgPart2}`
} }
); );
@ -184,7 +184,7 @@ assert.throws(
() => crypto.pbkdf2('pass', 'salt', i, 8, 'sha256', common.mustNotCall()), () => crypto.pbkdf2('pass', 'salt', i, 8, 'sha256', common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "iterations" argument must be of type number. ${received}` message: `The "iterations" argument must be of type number. ${received}`
} }
); );
@ -193,7 +193,7 @@ assert.throws(
() => crypto.pbkdf2Sync('pass', 'salt', i, 8, 'sha256'), () => crypto.pbkdf2Sync('pass', 'salt', i, 8, 'sha256'),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "iterations" argument must be of type number. ${received}` message: `The "iterations" argument must be of type number. ${received}`
} }
); );
@ -226,7 +226,7 @@ assert.throws(
() => crypto.pbkdf2('pass', 'salt', 8, 8, 'md55', common.mustNotCall()), () => crypto.pbkdf2('pass', 'salt', 8, 8, 'md55', common.mustNotCall()),
{ {
code: 'ERR_CRYPTO_INVALID_DIGEST', code: 'ERR_CRYPTO_INVALID_DIGEST',
name: 'TypeError [ERR_CRYPTO_INVALID_DIGEST]', name: 'TypeError',
message: 'Invalid digest: md55' message: 'Invalid digest: md55'
} }
); );
@ -235,7 +235,7 @@ assert.throws(
() => crypto.pbkdf2Sync('pass', 'salt', 8, 8, 'md55'), () => crypto.pbkdf2Sync('pass', 'salt', 8, 8, 'md55'),
{ {
code: 'ERR_CRYPTO_INVALID_DIGEST', code: 'ERR_CRYPTO_INVALID_DIGEST',
name: 'TypeError [ERR_CRYPTO_INVALID_DIGEST]', name: 'TypeError',
message: 'Invalid digest: md55' message: 'Invalid digest: md55'
} }
); );

View File

@ -44,7 +44,7 @@ common.expectWarning('DeprecationWarning',
[undefined, null, false, true, {}, []].forEach((value) => { [undefined, null, false, true, {}, []].forEach((value) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "size" argument must be of type number. ' + message: 'The "size" argument must be of type number. ' +
`Received type ${typeof value}` `Received type ${typeof value}`
}; };
@ -55,7 +55,7 @@ common.expectWarning('DeprecationWarning',
[-1, NaN, 2 ** 32].forEach((value) => { [-1, NaN, 2 ** 32].forEach((value) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "size" is out of range. It must be >= 0 && <= ' + message: 'The value of "size" is out of range. It must be >= 0 && <= ' +
`${kMaxPossibleLength}. Received ${value}` `${kMaxPossibleLength}. Received ${value}`
}; };
@ -199,7 +199,7 @@ common.expectWarning('DeprecationWarning',
const typeErrObj = { const typeErrObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "offset" argument must be of type number. ' + message: 'The "offset" argument must be of type number. ' +
'Received type string' 'Received type string'
}; };
@ -222,7 +222,7 @@ common.expectWarning('DeprecationWarning',
[NaN, kMaxPossibleLength + 1, -10, (-1 >>> 0) + 1].forEach((offsetSize) => { [NaN, kMaxPossibleLength + 1, -10, (-1 >>> 0) + 1].forEach((offsetSize) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
`It must be >= 0 && <= 10. Received ${offsetSize}` `It must be >= 0 && <= 10. Received ${offsetSize}`
}; };
@ -245,7 +245,7 @@ common.expectWarning('DeprecationWarning',
const rangeErrObj = { const rangeErrObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "size + offset" is out of range. ' + message: 'The value of "size + offset" is out of range. ' +
'It must be <= 10. Received 11' 'It must be <= 10. Received 11'
}; };
@ -265,7 +265,7 @@ assert.throws(
() => crypto.randomBytes((-1 >>> 0) + 1), () => crypto.randomBytes((-1 >>> 0) + 1),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "size" is out of range. ' + message: 'The value of "size" is out of range. ' +
`It must be >= 0 && <= ${kMaxPossibleLength}. Received 4294967296` `It must be >= 0 && <= ${kMaxPossibleLength}. Received 4294967296`
} }

View File

@ -323,7 +323,7 @@ common.expectsError(
const type = typeof input; const type = typeof input;
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "algorithm" argument must be of type string. ' + message: 'The "algorithm" argument must be of type string. ' +
`Received type ${type}` `Received type ${type}`
}; };
@ -350,7 +350,7 @@ common.expectsError(
const type = typeof input; const type = typeof input;
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "key" argument must be one of type string, Buffer, ' + message: 'The "key" argument must be one of type string, Buffer, ' +
`TypedArray, DataView, or KeyObject. Received type ${type}` `TypedArray, DataView, or KeyObject. Received type ${type}`
}; };

View File

@ -25,7 +25,7 @@ const client = dgram.createSocket('udp4').bind(0, () => {
[[], 1, true].forEach((invalidInput) => { [[], 1, true].forEach((invalidInput) => {
const expectedError = { const expectedError = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "address" argument must be one of type string or falsy. ' + message: 'The "address" argument must be one of type string or falsy. ' +
`Received type ${typeof invalidInput}` `Received type ${typeof invalidInput}`
}; };

View File

@ -6,7 +6,7 @@ const socket = dgram.createSocket('udp4');
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "offset" argument must be of type number. Received type ' + message: 'The "offset" argument must be of type number. Received type ' +
'undefined' 'undefined'
}; };

View File

@ -19,7 +19,7 @@ const promiseResolver = new dns.promises.Resolver();
].forEach((val) => { ].forEach((val) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "servers" argument must be of type Array. Received type ' + message: 'The "servers" argument must be of type Array. Received type ' +
typeof val typeof val
}; };
@ -59,7 +59,7 @@ const promiseResolver = new dns.promises.Resolver();
].forEach((val) => { ].forEach((val) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "servers[0]" argument must be of type string. ' + message: 'The "servers[0]" argument must be of type string. ' +
`Received type ${typeof val[0]}` `Received type ${typeof val[0]}`
}; };

View File

@ -81,7 +81,7 @@ assert(existing.length > 0);
dns.setServers([serv]); dns.setServers([serv]);
}, },
{ {
name: 'TypeError [ERR_INVALID_IP_ADDRESS]', name: 'TypeError',
code: 'ERR_INVALID_IP_ADDRESS' code: 'ERR_INVALID_IP_ADDRESS'
} }
); );

View File

@ -41,6 +41,6 @@ assert.strictEqual(cycle(Function), '[Function: Function]');
{ {
const err = new ERR_INVALID_ARG_TYPE('object', 'Object', 42); const err = new ERR_INVALID_ARG_TYPE('object', 'Object', 42);
assert(/^TypeError \[ERR_INVALID_ARG_TYPE\]:/.test(err)); assert(/^TypeError \[ERR_INVALID_ARG_TYPE\]:/.test(err));
assert.strictEqual(err.name, 'TypeError [ERR_INVALID_ARG_TYPE]'); assert.strictEqual(err.name, 'TypeError');
assert.strictEqual(err.code, 'ERR_INVALID_ARG_TYPE'); assert.strictEqual(err.code, 'ERR_INVALID_ARG_TYPE');
} }

View File

@ -6,7 +6,7 @@ const assert = require('assert');
const { E, SystemError, codes } = require('internal/errors'); const { E, SystemError, codes } = require('internal/errors');
assert.throws( assert.throws(
() => { throw new SystemError(); }, () => { new SystemError(); },
{ {
name: 'TypeError', name: 'TypeError',
message: 'Cannot read property \'match\' of undefined' message: 'Cannot read property \'match\' of undefined'
@ -29,7 +29,7 @@ const { ERR_TEST } = codes;
() => { throw new ERR_TEST(ctx); }, () => { throw new ERR_TEST(ctx); },
{ {
code: 'ERR_TEST', code: 'ERR_TEST',
name: 'SystemError [ERR_TEST]', name: 'SystemError',
message: 'custom message: syscall_test returned ETEST (code message)' + message: 'custom message: syscall_test returned ETEST (code message)' +
' /str => /str2', ' /str => /str2',
info: ctx info: ctx
@ -49,7 +49,7 @@ const { ERR_TEST } = codes;
() => { throw new ERR_TEST(ctx); }, () => { throw new ERR_TEST(ctx); },
{ {
code: 'ERR_TEST', code: 'ERR_TEST',
name: 'SystemError [ERR_TEST]', name: 'SystemError',
message: 'custom message: syscall_test returned ETEST (code message)' + message: 'custom message: syscall_test returned ETEST (code message)' +
' /buf => /str2', ' /buf => /str2',
info: ctx info: ctx
@ -69,7 +69,7 @@ const { ERR_TEST } = codes;
() => { throw new ERR_TEST(ctx); }, () => { throw new ERR_TEST(ctx); },
{ {
code: 'ERR_TEST', code: 'ERR_TEST',
name: 'SystemError [ERR_TEST]', name: 'SystemError',
message: 'custom message: syscall_test returned ETEST (code message)' + message: 'custom message: syscall_test returned ETEST (code message)' +
' /buf => /buf2', ' /buf => /buf2',
info: ctx info: ctx
@ -121,12 +121,12 @@ const { ERR_TEST } = codes;
assert.throws( assert.throws(
() => { () => {
const err = new ERR_TEST(ctx); const err = new ERR_TEST(ctx);
err.name = 'SystemError [CUSTOM_ERR_TEST]'; err.name = 'Foobar';
throw err; throw err;
}, },
{ {
code: 'ERR_TEST', code: 'ERR_TEST',
name: 'SystemError [CUSTOM_ERR_TEST]', name: 'Foobar',
message: 'custom message: syscall_test returned ERR_TEST ' + message: 'custom message: syscall_test returned ERR_TEST ' +
'(Error occurred)', '(Error occurred)',
info: ctx info: ctx

View File

@ -150,7 +150,7 @@ if (fs.lchmod) {
[false, 1, {}, [], null, undefined].forEach((input) => { [false, 1, {}, [], null, undefined].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "path" argument must be one of type string, Buffer, or URL.' + message: 'The "path" argument must be one of type string, Buffer, or URL.' +
` Received type ${typeof input}` ` Received type ${typeof input}`
}; };

View File

@ -10,7 +10,7 @@ const fs = require('fs');
['', false, null, undefined, {}, []].forEach((input) => { ['', false, null, undefined, {}, []].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. ' + message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof input}` `Received type ${typeof input}`
}; };

View File

@ -11,7 +11,7 @@ const fs = require('fs');
[false, null, undefined, {}, [], ''].forEach((input) => { [false, null, undefined, {}, [], ''].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. Received type ' + message: 'The "fd" argument must be of type number. Received type ' +
typeof input typeof input
}; };
@ -23,7 +23,7 @@ const fs = require('fs');
[false, null, undefined, {}, [], '', '123x'].forEach((input) => { [false, null, undefined, {}, [], '', '123x'].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_VALUE', code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError [ERR_INVALID_ARG_VALUE]', name: 'TypeError',
message: 'The argument \'mode\' must be a 32-bit unsigned integer or an ' + message: 'The argument \'mode\' must be a 32-bit unsigned integer or an ' +
`octal string. Received ${util.inspect(input)}` `octal string. Received ${util.inspect(input)}`
}; };
@ -34,7 +34,7 @@ const fs = require('fs');
[-1, 2 ** 32].forEach((input) => { [-1, 2 ** 32].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "fd" is out of range. It must be >= 0 && <= ' + message: 'The value of "fd" is out of range. It must be >= 0 && <= ' +
`2147483647. Received ${input}` `2147483647. Received ${input}`
}; };
@ -45,7 +45,7 @@ const fs = require('fs');
[-1, 2 ** 32].forEach((input) => { [-1, 2 ** 32].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "mode" is out of range. It must be >= 0 && <= ' + message: 'The value of "mode" is out of range. It must be >= 0 && <= ' +
`4294967295. Received ${input}` `4294967295. Received ${input}`
}; };
@ -57,7 +57,7 @@ const fs = require('fs');
[NaN, Infinity].forEach((input) => { [NaN, Infinity].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "fd" is out of range. It must be an integer. ' + message: 'The value of "fd" is out of range. It must be an integer. ' +
`Received ${input}` `Received ${input}`
}; };
@ -71,7 +71,7 @@ const fs = require('fs');
[1.5].forEach((input) => { [1.5].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "fd" is out of range. It must be an integer. ' + message: 'The value of "fd" is out of range. It must be an integer. ' +
`Received ${input}` `Received ${input}`
}; };

View File

@ -18,7 +18,7 @@ function test(input, errObj) {
['', false, null, undefined, {}, []].forEach((input) => { ['', false, null, undefined, {}, []].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. Received type ' + message: 'The "fd" argument must be of type number. Received type ' +
typeof input typeof input
}; };
@ -28,7 +28,7 @@ function test(input, errObj) {
[Infinity, NaN].forEach((input) => { [Infinity, NaN].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "fd" is out of range. It must be an integer. ' + message: 'The value of "fd" is out of range. It must be an integer. ' +
`Received ${input}` `Received ${input}`
}; };
@ -38,7 +38,7 @@ function test(input, errObj) {
[-1, 2 ** 32].forEach((input) => { [-1, 2 ** 32].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "fd" is out of range. It must be ' + message: 'The value of "fd" is out of range. It must be ' +
`>= 0 && < 4294967296. Received ${input}` `>= 0 && < 4294967296. Received ${input}`
}; };

View File

@ -53,7 +53,7 @@ fs.open(fileTemp, 'a', 0o777, common.mustCall(function(err, fd) {
['', false, null, undefined, {}, []].forEach((input) => { ['', false, null, undefined, {}, []].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. Received type ' + message: 'The "fd" argument must be of type number. Received type ' +
typeof input typeof input
}; };

View File

@ -41,7 +41,7 @@ assert.throws(() => fs.lchmod(f, {}), { code: 'ERR_INVALID_CALLBACK' });
[false, null, undefined, {}, [], '', '123x'].forEach((input) => { [false, null, undefined, {}, [], '', '123x'].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_VALUE', code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError [ERR_INVALID_ARG_VALUE]', name: 'TypeError',
message: 'The argument \'mode\' must be a 32-bit unsigned integer or an ' + message: 'The argument \'mode\' must be a 32-bit unsigned integer or an ' +
`octal string. Received ${util.inspect(input)}` `octal string. Received ${util.inspect(input)}`
}; };
@ -53,7 +53,7 @@ assert.throws(() => fs.lchmod(f, {}), { code: 'ERR_INVALID_CALLBACK' });
[-1, 2 ** 32].forEach((input) => { [-1, 2 ** 32].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "mode" is out of range. It must be >= 0 && <= ' + message: 'The value of "mode" is out of range. It must be >= 0 && <= ' +
`4294967295. Received ${input}` `4294967295. Received ${input}`
}; };

View File

@ -102,7 +102,7 @@ for (const extra of [[], ['r'], ['r', 0], ['r', 0, 'bad callback']]) {
fs.promises.open(i, 'r'), fs.promises.open(i, 'r'),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
}); });

View File

@ -164,7 +164,7 @@ async function getHandle(dest) {
}, },
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "gid" is out of range. ' + message: 'The value of "gid" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1' 'It must be >= 0 && < 4294967296. Received -1'
}); });
@ -175,7 +175,7 @@ async function getHandle(dest) {
}, },
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "gid" is out of range. ' + message: 'The value of "gid" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1' 'It must be >= 0 && < 4294967296. Received -1'
}); });
@ -336,7 +336,7 @@ async function getHandle(dest) {
async () => mkdir(dir, { recursive }), async () => mkdir(dir, { recursive }),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "recursive" argument must be of type boolean. ' + message: 'The "recursive" argument must be of type boolean. ' +
`Received type ${typeof recursive}` `Received type ${typeof recursive}`
} }
@ -352,7 +352,7 @@ async function getHandle(dest) {
async () => mkdtemp(1), async () => mkdtemp(1),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
} }

View File

@ -14,7 +14,7 @@ assert.throws(
() => fs.read(fd, expected.length, 0, 'utf-8', common.mustNotCall()), () => fs.read(fd, expected.length, 0, 'utf-8', common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "buffer" argument must be one of type Buffer, TypedArray, ' + message: 'The "buffer" argument must be one of type Buffer, TypedArray, ' +
'or DataView. Received type number' 'or DataView. Received type number'
} }
@ -30,7 +30,7 @@ assert.throws(
common.mustNotCall()); common.mustNotCall());
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. ' + message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof value}` `Received type ${typeof value}`
}); });
@ -45,7 +45,7 @@ assert.throws(() => {
common.mustNotCall()); common.mustNotCall());
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. It must be >= 0 && <= 4. ' + message: 'The value of "offset" is out of range. It must be >= 0 && <= 4. ' +
'Received -1' 'Received -1'
}); });
@ -59,7 +59,7 @@ assert.throws(() => {
common.mustNotCall()); common.mustNotCall());
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "length" is out of range. ' + message: 'The value of "length" is out of range. ' +
'It must be >= 0 && <= 4. Received -1' 'It must be >= 0 && <= 4. Received -1'
}); });
@ -69,7 +69,7 @@ assert.throws(
() => fs.readSync(fd, expected.length, 0, 'utf-8'), () => fs.readSync(fd, expected.length, 0, 'utf-8'),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "buffer" argument must be one of type Buffer, TypedArray, ' + message: 'The "buffer" argument must be one of type Buffer, TypedArray, ' +
'or DataView. Received type number' 'or DataView. Received type number'
} }
@ -84,7 +84,7 @@ assert.throws(
0); 0);
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. ' + message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof value}` `Received type ${typeof value}`
}); });
@ -98,7 +98,7 @@ assert.throws(() => {
0); 0);
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "offset" is out of range. ' + message: 'The value of "offset" is out of range. ' +
'It must be >= 0 && <= 4. Received -1' 'It must be >= 0 && <= 4. Received -1'
}); });
@ -111,7 +111,7 @@ assert.throws(() => {
0); 0);
}, { }, {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "length" is out of range. ' + message: 'The value of "length" is out of range. ' +
'It must be >= 0 && <= 4. Received -1' 'It must be >= 0 && <= 4. Received -1'
}); });

View File

@ -10,7 +10,7 @@ const fs = require('fs');
() => fs.rename(input, 'does-not-exist', common.mustNotCall()), () => fs.rename(input, 'does-not-exist', common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "oldPath" argument must be one ${type}` message: `The "oldPath" argument must be one ${type}`
} }
); );
@ -18,7 +18,7 @@ const fs = require('fs');
() => fs.rename('does-not-exist', input, common.mustNotCall()), () => fs.rename('does-not-exist', input, common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "newPath" argument must be one ${type}` message: `The "newPath" argument must be one ${type}`
} }
); );
@ -26,7 +26,7 @@ const fs = require('fs');
() => fs.renameSync(input, 'does-not-exist'), () => fs.renameSync(input, 'does-not-exist'),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "oldPath" argument must be one ${type}` message: `The "oldPath" argument must be one ${type}`
} }
); );
@ -34,7 +34,7 @@ const fs = require('fs');
() => fs.renameSync('does-not-exist', input), () => fs.renameSync('does-not-exist', input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: `The "newPath" argument must be one ${type}` message: `The "newPath" argument must be one ${type}`
} }
); );

View File

@ -134,7 +134,7 @@ fs.stat(__filename, common.mustCall(function(err, s) {
() => fs[fnName](input), () => fs[fnName](input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. ' + message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof input}` `Received type ${typeof input}`
} }
@ -147,28 +147,28 @@ fs.stat(__filename, common.mustCall(function(err, s) {
() => fs.lstat(input, common.mustNotCall()), () => fs.lstat(input, common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
assert.throws( assert.throws(
() => fs.lstatSync(input), () => fs.lstatSync(input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
assert.throws( assert.throws(
() => fs.stat(input, common.mustNotCall()), () => fs.stat(input, common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
assert.throws( assert.throws(
() => fs.statSync(input), () => fs.statSync(input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
}); });

View File

@ -61,7 +61,7 @@ fs.symlink(linkData, linkPath, common.mustCall(function(err) {
[false, 1, {}, [], null, undefined].forEach((input) => { [false, 1, {}, [], null, undefined].forEach((input) => {
const errObj = { const errObj = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "target" argument must be one of type string, Buffer, or ' + message: 'The "target" argument must be one of type string, Buffer, or ' +
`URL. Received type ${typeof input}` `URL. Received type ${typeof input}`
}; };
@ -75,7 +75,7 @@ fs.symlink(linkData, linkPath, common.mustCall(function(err) {
const errObj = { const errObj = {
code: 'ERR_FS_INVALID_SYMLINK_TYPE', code: 'ERR_FS_INVALID_SYMLINK_TYPE',
name: 'Error [ERR_FS_INVALID_SYMLINK_TYPE]', name: 'Error',
message: message:
'Symlink type must be one of "dir", "file", or "junction". Received "🍏"' 'Symlink type must be one of "dir", "file", or "junction". Received "🍏"'
}; };

View File

@ -183,7 +183,7 @@ function testFtruncate(cb) {
() => fs.truncate(file5, input, common.mustNotCall()), () => fs.truncate(file5, input, common.mustNotCall()),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "len" argument must be of type number. ' + message: 'The "len" argument must be of type number. ' +
`Received type ${typeof input}` `Received type ${typeof input}`
} }
@ -193,7 +193,7 @@ function testFtruncate(cb) {
() => fs.ftruncate(fd, input), () => fs.ftruncate(fd, input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "len" argument must be of type number. ' + message: 'The "len" argument must be of type number. ' +
`Received type ${typeof input}` `Received type ${typeof input}`
} }
@ -205,7 +205,7 @@ function testFtruncate(cb) {
() => fs.truncate(file5, input), () => fs.truncate(file5, input),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "len" is out of range. It must be ' + message: 'The value of "len" is out of range. It must be ' +
`an integer. Received ${input}` `an integer. Received ${input}`
} }
@ -215,7 +215,7 @@ function testFtruncate(cb) {
() => fs.ftruncate(fd, input), () => fs.ftruncate(fd, input),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "len" is out of range. It must be ' + message: 'The value of "len" is out of range. It must be ' +
`an integer. Received ${input}` `an integer. Received ${input}`
} }
@ -267,7 +267,7 @@ function testFtruncate(cb) {
() => fs.truncate('/foo/bar', input), () => fs.truncate('/foo/bar', input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "len" argument must be of type number. ' + message: 'The "len" argument must be of type number. ' +
`Received type ${typeof input}` `Received type ${typeof input}`
} }
@ -280,7 +280,7 @@ function testFtruncate(cb) {
() => fs[fnName](input), () => fs[fnName](input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "fd" argument must be of type number. ' + message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof input}` `Received type ${typeof input}`
} }

View File

@ -37,7 +37,7 @@ server.once('request', common.mustCall((req, res) => {
const expectedError = { const expectedError = {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
}; };
// Write should not accept an Array // Write should not accept an Array

View File

@ -33,7 +33,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc('h2=":8000"', input), () => session.altsvc('h2=":8000"', input),
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "originOrStream" is out of ' + message: 'The value of "originOrStream" is out of ' +
`range. It must be > 0 && < 4294967296. Received ${input}` `range. It must be > 0 && < 4294967296. Received ${input}`
} }
@ -46,7 +46,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc(input), () => session.altsvc(input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
}); });
@ -56,7 +56,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc(input), () => session.altsvc(input),
{ {
code: 'ERR_INVALID_CHAR', code: 'ERR_INVALID_CHAR',
name: 'TypeError [ERR_INVALID_CHAR]', name: 'TypeError',
message: 'Invalid character in alt' message: 'Invalid character in alt'
} }
); );
@ -67,7 +67,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc('clear', input), () => session.altsvc('clear', input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
}); });
@ -82,7 +82,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc('h2=":8000', input), () => session.altsvc('h2=":8000', input),
{ {
code: 'ERR_HTTP2_ALTSVC_INVALID_ORIGIN', code: 'ERR_HTTP2_ALTSVC_INVALID_ORIGIN',
name: 'TypeError [ERR_HTTP2_ALTSVC_INVALID_ORIGIN]', name: 'TypeError',
message: 'HTTP/2 ALTSVC frames require a valid origin' message: 'HTTP/2 ALTSVC frames require a valid origin'
} }
); );
@ -96,7 +96,7 @@ server.on('session', common.mustCall((session) => {
}, },
{ {
code: 'ERR_HTTP2_ALTSVC_LENGTH', code: 'ERR_HTTP2_ALTSVC_LENGTH',
name: 'TypeError [ERR_HTTP2_ALTSVC_LENGTH]', name: 'TypeError',
message: 'HTTP/2 ALTSVC frames are limited to 16382 bytes' message: 'HTTP/2 ALTSVC frames are limited to 16382 bytes'
} }
); );

View File

@ -27,7 +27,7 @@ server.listen(0, common.mustCall(() => {
client.on('error', common.expectsError({ client.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR', code: 'ERR_HTTP2_ERROR',
type: NghttpError, type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]', name: 'Error',
message: 'Protocol error' message: 'Protocol error'
})); }));

View File

@ -55,7 +55,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: { error: {
code: 'ERR_HTTP2_ERROR', code: 'ERR_HTTP2_ERROR',
type: NghttpError, type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]', name: 'Error',
message: nghttp2ErrorString(constants[key]) message: nghttp2ErrorString(constants[key])
}, },
type: 'session' type: 'session'

View File

@ -21,7 +21,7 @@ server.listen(0, common.mustCall(() => {
assert.throws( assert.throws(
() => req.close(2 ** 32), () => req.close(2 ** 32),
{ {
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
message: 'The value of "code" is out of range. It must be ' + message: 'The value of "code" is out of range. It must be ' +
'>= 0 && <= 4294967295. Received 4294967296' '>= 0 && <= 4294967295. Received 4294967296'

View File

@ -49,7 +49,7 @@ server.listen(0, common.mustCall(function() {
() => request.method = ' ', () => request.method = ' ',
{ {
code: 'ERR_INVALID_ARG_VALUE', code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError [ERR_INVALID_ARG_VALUE]', name: 'TypeError',
message: "The argument 'method' is invalid. Received ' '" message: "The argument 'method' is invalid. Received ' '"
} }
); );
@ -57,7 +57,7 @@ server.listen(0, common.mustCall(function() {
() => request.method = true, () => request.method = true,
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "method" argument must be of type string. ' + message: 'The "method" argument must be of type string. ' +
'Received type boolean' 'Received type boolean'
} }

View File

@ -46,7 +46,7 @@ server.listen(0, common.mustCall(function() {
() => response[fnName](), () => response[fnName](),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "name" argument must be of type string. Received ' + message: 'The "name" argument must be of type string. Received ' +
'type undefined' 'type undefined'
} }

View File

@ -13,7 +13,7 @@ invalidOptions.forEach((invalidOption) => {
assert.throws( assert.throws(
() => http2.createSecureServer(invalidOption), () => http2.createSecureServer(invalidOption),
{ {
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
message: 'The "options" argument must be of type Object. Received ' + message: 'The "options" argument must be of type Object. Received ' +
`type ${typeof invalidOption}` `type ${typeof invalidOption}`

View File

@ -28,7 +28,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: { error: {
code: 'ERR_HTTP2_ERROR', code: 'ERR_HTTP2_ERROR',
type: NghttpError, type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]', name: 'Error',
message: nghttp2ErrorString(constants[key]) message: nghttp2ErrorString(constants[key])
}, },
type: 'stream' type: 'stream'

View File

@ -46,7 +46,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
() => session.origin(input), () => session.origin(input),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]' name: 'TypeError'
} }
); );
}); });
@ -56,7 +56,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
() => session.origin(input), () => session.origin(input),
{ {
code: 'ERR_HTTP2_INVALID_ORIGIN', code: 'ERR_HTTP2_INVALID_ORIGIN',
name: 'TypeError [ERR_HTTP2_INVALID_ORIGIN]' name: 'TypeError'
} }
); );
}); });
@ -66,7 +66,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
() => session.origin(input), () => session.origin(input),
{ {
code: 'ERR_INVALID_URL', code: 'ERR_INVALID_URL',
name: 'TypeError [ERR_INVALID_URL]' name: 'TypeError'
} }
); );
}); });
@ -75,7 +75,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
() => session.origin(longInput), () => session.origin(longInput),
{ {
code: 'ERR_HTTP2_ORIGIN_LENGTH', code: 'ERR_HTTP2_ORIGIN_LENGTH',
name: 'TypeError [ERR_HTTP2_ORIGIN_LENGTH]' name: 'TypeError'
} }
); );
})); }));

View File

@ -29,7 +29,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: { error: {
code: 'ERR_HTTP2_ERROR', code: 'ERR_HTTP2_ERROR',
type: NghttpError, type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]', name: 'Error',
message: nghttp2ErrorString(constants[key]) message: nghttp2ErrorString(constants[key])
}, },
type: 'stream' type: 'stream'

View File

@ -36,7 +36,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: { error: {
code: 'ERR_HTTP2_ERROR', code: 'ERR_HTTP2_ERROR',
type: NghttpError, type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]', name: 'Error',
message: nghttp2ErrorString(constants[key]) message: nghttp2ErrorString(constants[key])
}, },
type: 'stream' type: 'stream'

View File

@ -31,7 +31,7 @@ server.on('stream', common.mustCall((stream, headers) => {
() => stream.pushStream({ 'connection': 'test' }, {}, () => {}), () => stream.pushStream({ 'connection': 'test' }, {}, () => {}),
{ {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: "connection"' message: 'HTTP/1 Connection specific headers are forbidden: "connection"'
} }
); );

View File

@ -53,7 +53,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: { error: {
code: 'ERR_HTTP2_ERROR', code: 'ERR_HTTP2_ERROR',
type: NghttpError, type: NghttpError,
name: 'Error [ERR_HTTP2_ERROR]', name: 'Error',
message: nghttp2ErrorString(constants[key]) message: nghttp2ErrorString(constants[key])
}, },
type: 'stream' type: 'stream'

View File

@ -283,7 +283,7 @@ const {
].forEach((name) => { ].forEach((name) => {
common.expectsError(() => mapToHeaders({ [name]: 'abc' }), { common.expectsError(() => mapToHeaders({ [name]: 'abc' }), {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: ' + message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${name.toLowerCase()}"` `"${name.toLowerCase()}"`
}); });
@ -291,7 +291,7 @@ const {
common.expectsError(() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }), { common.expectsError(() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }), {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: ' + message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"` `"${HTTP2_HEADER_TE}"`
}); });
@ -299,7 +299,7 @@ common.expectsError(() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }), {
common.expectsError( common.expectsError(
() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] }), { () => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] }), {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: ' + message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"` `"${HTTP2_HEADER_TE}"`
}); });

View File

@ -87,7 +87,7 @@ const caArrDataView = toDataView(caCert);
https.createServer({ key, cert }); https.createServer({ key, cert });
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "options.key" property must be one of type string, Buffer, ' + message: 'The "options.key" property must be one of type string, Buffer, ' +
`TypedArray, or DataView. Received type ${type}` `TypedArray, or DataView. Received type ${type}`
}); });
@ -112,7 +112,7 @@ const caArrDataView = toDataView(caCert);
https.createServer({ key, cert }); https.createServer({ key, cert });
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "options.cert" property must be one of type string, Buffer,' + message: 'The "options.cert" property must be one of type string, Buffer,' +
` TypedArray, or DataView. Received type ${type}` ` TypedArray, or DataView. Received type ${type}`
}); });
@ -146,7 +146,7 @@ const caArrDataView = toDataView(caCert);
https.createServer({ key, cert, ca }); https.createServer({ key, cert, ca });
}, { }, {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "options.ca" property must be one of type string, Buffer, ' + message: 'The "options.ca" property must be one of type string, Buffer, ' +
`TypedArray, or DataView. Received type ${type}` `TypedArray, or DataView. Received type ${type}`
}); });

View File

@ -17,7 +17,7 @@ errors.E('TEST_ERROR_1', 'Error for testing purposes: %s',
{ {
const err = new errors.codes.TEST_ERROR_1('test'); const err = new errors.codes.TEST_ERROR_1('test');
assert(err instanceof Error); assert(err instanceof Error);
assert.strictEqual(err.name, 'Error [TEST_ERROR_1]'); assert.strictEqual(err.name, 'Error');
} }
{ {
@ -31,5 +31,5 @@ errors.E('TEST_ERROR_1', 'Error for testing purposes: %s',
errors.useOriginalName = false; errors.useOriginalName = false;
const err = new errors.codes.TEST_ERROR_1('test'); const err = new errors.codes.TEST_ERROR_1('test');
assert(err instanceof Error); assert(err instanceof Error);
assert.strictEqual(err.name, 'Error [TEST_ERROR_1]'); assert.strictEqual(err.name, 'Error');
} }

View File

@ -20,7 +20,7 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
{ {
const err = new errors.codes.TEST_ERROR_1('test'); const err = new errors.codes.TEST_ERROR_1('test');
assert(err instanceof Error); assert(err instanceof Error);
assert.strictEqual(err.name, 'Error [TEST_ERROR_1]'); assert.strictEqual(err.name, 'Error');
assert.strictEqual(err.message, 'Error for testing purposes: test'); assert.strictEqual(err.message, 'Error for testing purposes: test');
assert.strictEqual(err.code, 'TEST_ERROR_1'); assert.strictEqual(err.code, 'TEST_ERROR_1');
} }
@ -28,7 +28,7 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
{ {
const err = new errors.codes.TEST_ERROR_1.TypeError('test'); const err = new errors.codes.TEST_ERROR_1.TypeError('test');
assert(err instanceof TypeError); assert(err instanceof TypeError);
assert.strictEqual(err.name, 'TypeError [TEST_ERROR_1]'); assert.strictEqual(err.name, 'TypeError');
assert.strictEqual(err.message, 'Error for testing purposes: test'); assert.strictEqual(err.message, 'Error for testing purposes: test');
assert.strictEqual(err.code, 'TEST_ERROR_1'); assert.strictEqual(err.code, 'TEST_ERROR_1');
} }
@ -36,7 +36,7 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
{ {
const err = new errors.codes.TEST_ERROR_1.RangeError('test'); const err = new errors.codes.TEST_ERROR_1.RangeError('test');
assert(err instanceof RangeError); assert(err instanceof RangeError);
assert.strictEqual(err.name, 'RangeError [TEST_ERROR_1]'); assert.strictEqual(err.name, 'RangeError');
assert.strictEqual(err.message, 'Error for testing purposes: test'); assert.strictEqual(err.message, 'Error for testing purposes: test');
assert.strictEqual(err.code, 'TEST_ERROR_1'); assert.strictEqual(err.code, 'TEST_ERROR_1');
} }
@ -44,7 +44,7 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
{ {
const err = new errors.codes.TEST_ERROR_2('abc', 'xyz'); const err = new errors.codes.TEST_ERROR_2('abc', 'xyz');
assert(err instanceof Error); assert(err instanceof Error);
assert.strictEqual(err.name, 'Error [TEST_ERROR_2]'); assert.strictEqual(err.name, 'Error');
assert.strictEqual(err.message, 'abc xyz'); assert.strictEqual(err.message, 'abc xyz');
assert.strictEqual(err.code, 'TEST_ERROR_2'); assert.strictEqual(err.code, 'TEST_ERROR_2');
} }
@ -79,27 +79,6 @@ common.expectsError(() => {
message: 'Error for testing purposes: a' message: 'Error for testing purposes: a'
}); });
common.expectsError(() => {
common.expectsError(() => {
throw new errors.codes.TEST_ERROR_1.TypeError('a');
}, { code: 'TEST_ERROR_1', type: RangeError });
}, {
code: 'ERR_ASSERTION',
message: /\+ type: \[Function: TypeError]\n- type: \[Function: RangeError]/
});
common.expectsError(() => {
common.expectsError(() => {
throw new errors.codes.TEST_ERROR_1.TypeError('a');
}, { code: 'TEST_ERROR_1',
type: TypeError,
message: /^Error for testing 2/ });
}, {
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: /\+ message: 'Error for testing purposes: a',\n- message: \/\^Error/
});
// Test that `code` property is mutable and that changing it does not change the // Test that `code` property is mutable and that changing it does not change the
// name. // name.
{ {
@ -113,7 +92,7 @@ common.expectsError(() => {
assert.strictEqual(myError.code, 'FHQWHGADS'); assert.strictEqual(myError.code, 'FHQWHGADS');
assert.strictEqual(myError.name, initialName); assert.strictEqual(myError.name, initialName);
assert.deepStrictEqual(Object.keys(myError), ['code']); assert.deepStrictEqual(Object.keys(myError), ['code']);
assert.ok(myError.name.includes('TEST_ERROR_1')); assert.ok(!myError.name.includes('TEST_ERROR_1'));
assert.ok(!myError.name.includes('FHQWHGADS')); assert.ok(!myError.name.includes('FHQWHGADS'));
} }

View File

@ -48,7 +48,7 @@ function testNextTickWith(val) {
}, },
{ {
code: 'ERR_INVALID_CALLBACK', code: 'ERR_INVALID_CALLBACK',
name: 'TypeError [ERR_INVALID_CALLBACK]', name: 'TypeError',
type: TypeError type: TypeError
} }
); );

View File

@ -37,7 +37,7 @@ assert.throws(
() => process.cpuUsage(1), () => process.cpuUsage(1),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "prevValue" argument must be of type object. ' + message: 'The "prevValue" argument must be of type object. ' +
'Received type number' 'Received type number'
} }
@ -53,7 +53,7 @@ assert.throws(
() => process.cpuUsage(value), () => process.cpuUsage(value),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "prevValue.user" property must be of type number. ' + message: 'The "prevValue.user" property must be of type number. ' +
`Received type ${typeof value.user}` `Received type ${typeof value.user}`
} }
@ -68,7 +68,7 @@ assert.throws(
() => process.cpuUsage(value), () => process.cpuUsage(value),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "prevValue.system" property must be of type number. ' + message: 'The "prevValue.system" property must be of type number. ' +
`Received type ${typeof value.system}` `Received type ${typeof value.system}`
} }
@ -84,7 +84,7 @@ assert.throws(
() => process.cpuUsage(value), () => process.cpuUsage(value),
{ {
code: 'ERR_INVALID_OPT_VALUE', code: 'ERR_INVALID_OPT_VALUE',
name: 'RangeError [ERR_INVALID_OPT_VALUE]', name: 'RangeError',
message: `The value "${value.user}" is invalid ` + message: `The value "${value.user}" is invalid ` +
'for option "prevValue.user"' 'for option "prevValue.user"'
} }
@ -99,7 +99,7 @@ assert.throws(
() => process.cpuUsage(value), () => process.cpuUsage(value),
{ {
code: 'ERR_INVALID_OPT_VALUE', code: 'ERR_INVALID_OPT_VALUE',
name: 'RangeError [ERR_INVALID_OPT_VALUE]', name: 'RangeError',
message: `The value "${value.system}" is invalid ` + message: `The value "${value.system}" is invalid ` +
'for option "prevValue.system"' 'for option "prevValue.system"'
} }

View File

@ -17,7 +17,7 @@ if (!common.isMainThread)
}, },
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: message:
'The "user" argument must be ' + 'The "user" argument must be ' +
'one of type number or string. ' + 'one of type number or string. ' +
@ -33,7 +33,7 @@ if (!common.isMainThread)
}, },
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: message:
'The "extraGroup" argument must be ' + 'The "extraGroup" argument must be ' +
'one of type number or string. ' + 'one of type number or string. ' +

View File

@ -41,7 +41,7 @@ const assert = require('assert');
['SIGTERM', null, undefined, NaN, Infinity, -Infinity].forEach((val) => { ['SIGTERM', null, undefined, NaN, Infinity, -Infinity].forEach((val) => {
assert.throws(() => process.kill(val), { assert.throws(() => process.kill(val), {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "pid" argument must be of type number. ' + message: 'The "pid" argument must be of type number. ' +
`Received type ${typeof val}` `Received type ${typeof val}`
}); });

View File

@ -16,7 +16,7 @@ assert.throws(
}, },
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "groups" argument must be of type Array. ' + message: 'The "groups" argument must be of type Array. ' +
'Received type undefined' 'Received type undefined'
} }
@ -28,7 +28,7 @@ assert.throws(
}, },
{ {
code: 'ERR_OUT_OF_RANGE', code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]', name: 'RangeError',
message: 'The value of "groups[1]" is out of range. ' + message: 'The value of "groups[1]" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1' 'It must be >= 0 && < 4294967296. Received -1'
} }
@ -41,7 +41,7 @@ assert.throws(
}, },
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "groups[0]" argument must be ' + message: 'The "groups[0]" argument must be ' +
'one of type number or string. ' + 'one of type number or string. ' +
`Received type ${typeof val}` `Received type ${typeof val}`

View File

@ -129,21 +129,21 @@ const { promisify } = require('util');
assert.throws( assert.throws(
() => finished(rs, 'foo'), () => finished(rs, 'foo'),
{ {
name: /ERR_INVALID_ARG_TYPE/, code: 'ERR_INVALID_ARG_TYPE',
message: /callback/ message: /callback/
} }
); );
assert.throws( assert.throws(
() => finished(rs, 'foo', () => {}), () => finished(rs, 'foo', () => {}),
{ {
name: /ERR_INVALID_ARG_TYPE/, code: 'ERR_INVALID_ARG_TYPE',
message: /opts/ message: /opts/
} }
); );
assert.throws( assert.throws(
() => finished(rs, {}, 'foo'), () => finished(rs, {}, 'foo'),
{ {
name: /ERR_INVALID_ARG_TYPE/, code: 'ERR_INVALID_ARG_TYPE',
message: /callback/ message: /callback/
} }
); );

View File

@ -14,7 +14,7 @@ assert.throws(
() => new tty.WriteStream(-1), () => new tty.WriteStream(-1),
{ {
code: 'ERR_INVALID_FD', code: 'ERR_INVALID_FD',
name: 'RangeError [ERR_INVALID_FD]', name: 'RangeError',
message: '"fd" must be a positive integer: -1' message: '"fd" must be a positive integer: -1'
} }
); );
@ -38,7 +38,7 @@ assert.throws(
}); });
}, { }, {
code: 'ERR_TTY_INIT_FAILED', code: 'ERR_TTY_INIT_FAILED',
name: 'SystemError [ERR_TTY_INIT_FAILED]', name: 'SystemError',
message, message,
info info
} }
@ -51,7 +51,7 @@ assert.throws(
}); });
}, { }, {
code: 'ERR_TTY_INIT_FAILED', code: 'ERR_TTY_INIT_FAILED',
name: 'SystemError [ERR_TTY_INIT_FAILED]', name: 'SystemError',
message, message,
info info
}); });
@ -61,7 +61,7 @@ assert.throws(
() => new tty.ReadStream(-1), () => new tty.ReadStream(-1),
{ {
code: 'ERR_INVALID_FD', code: 'ERR_INVALID_FD',
name: 'RangeError [ERR_INVALID_FD]', name: 'RangeError',
message: '"fd" must be a positive integer: -1' message: '"fd" must be a positive integer: -1'
} }
); );

View File

@ -26,7 +26,7 @@ assert.strictEqual(
() => url.format(myURL, value), () => url.format(myURL, value),
{ {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]', name: 'TypeError',
message: 'The "options" argument must be of type Object. ' + message: 'The "options" argument must be of type Object. ' +
`Received type ${typeof value}` `Received type ${typeof value}`
} }

View File

@ -56,15 +56,13 @@ for (const test of failureTests) {
assert.throws( assert.throws(
() => new URL(test.input, test.base), () => new URL(test.input, test.base),
(error) => { (error) => {
if (!expectedError(error)) expectedError(error);
return false;
// The input could be processed, so we don't do strict matching here // The input could be processed, so we don't do strict matching here
const match = (`${error}`).match(/Invalid URL: (.*)$/); let match;
if (!match) { assert(match = (`${error}`).match(/Invalid URL: (.*)$/));
return false; assert.strictEqual(error.input, match[1]);
} return true;
return error.input === match[1];
}); });
} }