summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-03-16 12:09:14 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-23 02:55:54 +0100
commit1ed3c54ecbd72a33693e5954f86bcc9fd9b1cc09 (patch)
treeb708974383e0c32b07b1c1525b10ba8426307737
parentc757cb1b9870de9297df736d5e831b7eb627644a (diff)
downloadandroid-node-v8-1ed3c54ecbd72a33693e5954f86bcc9fd9b1cc09.tar.gz
android-node-v8-1ed3c54ecbd72a33693e5954f86bcc9fd9b1cc09.tar.bz2
android-node-v8-1ed3c54ecbd72a33693e5954f86bcc9fd9b1cc09.zip
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>
-rw-r--r--lib/internal/assert/assertion_error.js15
-rw-r--r--lib/internal/errors.js65
-rw-r--r--lib/internal/http2/util.js6
-rw-r--r--test/parallel/test-assert-async.js6
-rw-r--r--test/parallel/test-assert-deep.js24
-rw-r--r--test/parallel/test-assert-fail-deprecation.js6
-rw-r--r--test/parallel/test-assert-fail.js4
-rw-r--r--test/parallel/test-assert-first-line.js4
-rw-r--r--test/parallel/test-assert.js30
-rw-r--r--test/parallel/test-buffer-alloc.js4
-rw-r--r--test/parallel/test-buffer-arraybuffer.js14
-rw-r--r--test/parallel/test-buffer-read.js4
-rw-r--r--test/parallel/test-buffer-readdouble.js6
-rw-r--r--test/parallel/test-buffer-readfloat.js6
-rw-r--r--test/parallel/test-buffer-readint.js14
-rw-r--r--test/parallel/test-buffer-readuint.js14
-rw-r--r--test/parallel/test-buffer-slow.js4
-rw-r--r--test/parallel/test-buffer-writedouble.js6
-rw-r--r--test/parallel/test-buffer-writefloat.js6
-rw-r--r--test/parallel/test-buffer-writeint.js10
-rw-r--r--test/parallel/test-buffer-writeuint.js10
-rw-r--r--test/parallel/test-child-process-fork.js6
-rw-r--r--test/parallel/test-crypto-pbkdf2.js30
-rw-r--r--test/parallel/test-crypto-random.js12
-rw-r--r--test/parallel/test-crypto-sign-verify.js4
-rw-r--r--test/parallel/test-dgram-send-address-types.js2
-rw-r--r--test/parallel/test-dgram-sendto.js2
-rw-r--r--test/parallel/test-dns-setservers-type-check.js4
-rw-r--r--test/parallel/test-dns.js2
-rw-r--r--test/parallel/test-error-serdes.js2
-rw-r--r--test/parallel/test-errors-systemerror.js12
-rw-r--r--test/parallel/test-fs-chmod.js2
-rw-r--r--test/parallel/test-fs-close-errors.js2
-rw-r--r--test/parallel/test-fs-fchmod.js12
-rw-r--r--test/parallel/test-fs-fchown.js6
-rw-r--r--test/parallel/test-fs-fsync.js2
-rw-r--r--test/parallel/test-fs-lchmod.js4
-rw-r--r--test/parallel/test-fs-open.js2
-rw-r--r--test/parallel/test-fs-promises.js8
-rw-r--r--test/parallel/test-fs-read-type.js16
-rw-r--r--test/parallel/test-fs-rename-type-check.js8
-rw-r--r--test/parallel/test-fs-stat.js10
-rw-r--r--test/parallel/test-fs-symlink.js4
-rw-r--r--test/parallel/test-fs-truncate.js12
-rw-r--r--test/parallel/test-http-res-write-end-dont-take-array.js2
-rw-r--r--test/parallel/test-http2-altsvc.js12
-rw-r--r--test/parallel/test-http2-client-http1-server.js2
-rw-r--r--test/parallel/test-http2-client-onconnect-errors.js2
-rw-r--r--test/parallel/test-http2-client-rststream-before-connect.js2
-rw-r--r--test/parallel/test-http2-compat-serverrequest-headers.js4
-rw-r--r--test/parallel/test-http2-compat-serverresponse-headers.js2
-rw-r--r--test/parallel/test-http2-createsecureserver-nooptions.js2
-rw-r--r--test/parallel/test-http2-info-headers-errors.js2
-rw-r--r--test/parallel/test-http2-origin.js8
-rw-r--r--test/parallel/test-http2-respond-nghttperrors.js2
-rw-r--r--test/parallel/test-http2-respond-with-fd-errors.js2
-rw-r--r--test/parallel/test-http2-server-push-stream-errors-args.js2
-rw-r--r--test/parallel/test-http2-server-push-stream-errors.js2
-rw-r--r--test/parallel/test-http2-util-headers-list.js6
-rw-r--r--test/parallel/test-https-options-boolean-check.js6
-rw-r--r--test/parallel/test-internal-error-original-names.js4
-rw-r--r--test/parallel/test-internal-errors.js31
-rw-r--r--test/parallel/test-next-tick-errors.js2
-rw-r--r--test/parallel/test-process-cpuUsage.js10
-rw-r--r--test/parallel/test-process-initgroups.js4
-rw-r--r--test/parallel/test-process-kill-pid.js2
-rw-r--r--test/parallel/test-process-setgroups.js6
-rw-r--r--test/parallel/test-stream-finished.js6
-rw-r--r--test/parallel/test-ttywrap-invalid-fd.js8
-rw-r--r--test/parallel/test-url-format-whatwg.js2
-rw-r--r--test/parallel/test-whatwg-url-custom-parsing.js12
71 files changed, 283 insertions, 284 deletions
diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js
index a13a610da1..ded5ef00c9 100644
--- a/lib/internal/assert/assertion_error.js
+++ b/lib/internal/assert/assertion_error.js
@@ -388,12 +388,25 @@ class AssertionError extends Error {
}
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.actual = actual;
this.expected = expected;
this.operator = operator;
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) {
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index d283fda143..536778db43 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -18,6 +18,8 @@ const codes = {};
const { kMaxLength } = internalBinding('buffer');
const { defineProperty } = Object;
+let useOriginalName = false;
+
// Lazily loaded
let util;
let assert;
@@ -74,19 +76,7 @@ class SystemError extends Error {
value: key,
writable: true
});
- }
-
- get name() {
- return `SystemError [${this[kCode]}]`;
- }
-
- set name(value) {
- defineProperty(this, 'name', {
- configurable: true,
- enumerable: true,
- value,
- writable: true
- });
+ addCodeToName(this, 'SystemError', key);
}
get code() {
@@ -141,6 +131,10 @@ class SystemError extends Error {
this[kInfo].dest = val ?
lazyBuffer().from(val.toString()) : undefined;
}
+
+ toString() {
+ return `${this.name} [${this.code}]: ${this.message}`;
+ }
}
function makeSystemErrorWithCode(key) {
@@ -151,8 +145,6 @@ function makeSystemErrorWithCode(key) {
};
}
-let useOriginalName = false;
-
function makeNodeErrorWithCode(Base, key) {
return class NodeError extends Base {
constructor(...args) {
@@ -164,22 +156,7 @@ function makeNodeErrorWithCode(Base, key) {
writable: true,
configurable: true
});
- }
-
- get name() {
- if (useOriginalName) {
- return super.name;
- }
- return `${super.name} [${key}]`;
- }
-
- set name(value) {
- defineProperty(this, 'name', {
- configurable: true,
- enumerable: true,
- value,
- writable: true
- });
+ addCodeToName(this, super.name, key);
}
get code() {
@@ -194,9 +171,35 @@ function makeNodeErrorWithCode(Base, key) {
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
// *only* to allow for testing.
function E(sym, val, def, ...otherClasses) {
diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js
index 81b28e2ed4..d1a2a2b9ad 100644
--- a/lib/internal/http2/util.js
+++ b/lib/internal/http2/util.js
@@ -498,6 +498,12 @@ class NghttpError extends Error {
this.code = 'ERR_HTTP2_ERROR';
this.name = 'Error [ERR_HTTP2_ERROR]';
this.errno = ret;
+ this.stack;
+ delete this.name;
+ }
+
+ toString() {
+ return `${this.name} [${this.code}]: ${this.message}`;
}
}
diff --git a/test/parallel/test-assert-async.js b/test/parallel/test-assert-async.js
index f148c7e3d8..c2b4220617 100644
--- a/test/parallel/test-assert-async.js
+++ b/test/parallel/test-assert-async.js
@@ -13,7 +13,7 @@ const promises = [];
const rejectingFn = async () => assert.fail();
const errObj = {
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: 'Failed'
};
// `assert.rejects` accepts a function or a promise as first argument.
@@ -38,7 +38,7 @@ const promises = [];
promise = assert.rejects(() => {}, common.mustNotCall());
promises.push(assert.rejects(promise, {
- name: 'TypeError [ERR_INVALID_RETURN_VALUE]',
+ name: 'TypeError',
code: 'ERR_INVALID_RETURN_VALUE',
message: 'Expected instance of Promise to be returned ' +
'from the "promiseFn" function but got type undefined.'
@@ -75,7 +75,7 @@ promises.push(assert.rejects(
message: 'Expected instance of Promise to be returned ' +
'from the "promiseFn" function but got instance of Map.',
code: 'ERR_INVALID_RETURN_VALUE',
- name: 'TypeError [ERR_INVALID_RETURN_VALUE]'
+ name: 'TypeError'
}));
promises.push(assert.doesNotReject(async () => {}));
promises.push(assert.doesNotReject(Promise.resolve()));
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js
index 407334d0ca..5b71173478 100644
--- a/test/parallel/test-assert-deep.js
+++ b/test/parallel/test-assert-deep.js
@@ -778,7 +778,7 @@ assert.throws(
assert.throws(
() => 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: ' +
util.inspect(new Date(2000, 3, 14))
}
@@ -790,35 +790,35 @@ assert.throws(
() => assert.deepStrictEqual(/ab/, /a/),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /ab/\n- /a/`
});
assert.throws(
() => assert.deepStrictEqual(/a/g, /a/),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /a/g\n- /a/`
});
assert.throws(
() => assert.deepStrictEqual(/a/i, /a/),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /a/i\n- /a/`
});
assert.throws(
() => assert.deepStrictEqual(/a/m, /a/),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n+ /a/m\n- /a/`
});
assert.throws(
() => assert.deepStrictEqual(/a/igm, /a/im),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
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']),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n [\n+ 4\n- '4'\n ]`
});
assert.throws(
() => assert.deepStrictEqual({ a: 4 }, { a: 4, b: true }),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n ` +
'{\n a: 4,\n- b: true\n }'
});
@@ -859,7 +859,7 @@ assert.throws(
() => assert.deepStrictEqual(['a'], { 0: 'a' }),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n` +
"+ [\n+ 'a'\n+ ]\n- {\n- '0': 'a'\n- }"
});
@@ -953,7 +953,7 @@ assert.deepStrictEqual(obj1, obj2);
() => assert.deepStrictEqual(a, b),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: /\.\.\./g
}
);
@@ -977,7 +977,7 @@ assert.throws(
() => assert.deepStrictEqual([1, 2, 3], [1, 2]),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${defaultMsgStartFull}\n\n` +
' [\n' +
' 1,\n' +
@@ -1063,7 +1063,7 @@ assert.throws(
() => assert.deepStrictEqual(a, b),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n /
}
);
diff --git a/test/parallel/test-assert-fail-deprecation.js b/test/parallel/test-assert-fail-deprecation.js
index 97cba760e0..5f51d27e3c 100644
--- a/test/parallel/test-assert-fail-deprecation.js
+++ b/test/parallel/test-assert-fail-deprecation.js
@@ -15,7 +15,7 @@ assert.throws(() => {
assert.fail('first', 'second');
}, {
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: '\'first\' != \'second\'',
operator: '!=',
actual: 'first',
@@ -28,7 +28,7 @@ assert.throws(() => {
assert.fail('ignored', 'ignored', 'another custom message');
}, {
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: 'another custom message',
operator: 'fail',
actual: 'ignored',
@@ -49,7 +49,7 @@ assert.throws(() => {
assert.fail('first', 'second', undefined, 'operator');
}, {
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: '\'first\' operator \'second\'',
operator: 'operator',
actual: 'first',
diff --git a/test/parallel/test-assert-fail.js b/test/parallel/test-assert-fail.js
index 4410cc8544..51c69372dd 100644
--- a/test/parallel/test-assert-fail.js
+++ b/test/parallel/test-assert-fail.js
@@ -8,7 +8,7 @@ assert.throws(
() => { assert.fail(); },
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: 'Failed',
operator: 'fail',
actual: undefined,
@@ -22,7 +22,7 @@ assert.throws(() => {
assert.fail('custom message');
}, {
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: 'custom message',
operator: 'fail',
actual: undefined,
diff --git a/test/parallel/test-assert-first-line.js b/test/parallel/test-assert-first-line.js
index 32eadbf741..f9d4a8b06c 100644
--- a/test/parallel/test-assert-first-line.js
+++ b/test/parallel/test-assert-first-line.js
@@ -9,7 +9,7 @@ const { path } = require('../common/fixtures');
assert.throws(
() => 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"
}
);
@@ -17,7 +17,7 @@ assert.throws(
assert.throws(
() => require(path('assert-long-line')),
{
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: "The expression evaluated to a falsy value:\n\n assert.ok('')\n"
}
);
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index 5bca70a01d..4c2b1f978d 100644
--- a/test/parallel/test-assert.js
+++ b/test/parallel/test-assert.js
@@ -73,7 +73,7 @@ assert.throws(
() => a.notStrictEqual(2, 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: ' +
`'${'a '.repeat(30)}'`,
- name: 'AssertionError [ERR_ASSERTION]'
+ name: 'AssertionError'
}
);
@@ -141,7 +141,7 @@ assert.throws(() => thrower(TypeError));
assert.throws(
() => a.doesNotThrow(() => thrower(Error), 'user message'),
{
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
code: 'ERR_ASSERTION',
operator: 'doesNotThrow',
message: 'Got unwanted exception: user message\n' +
@@ -400,7 +400,7 @@ assert.throws(() => {
() => new assert.AssertionError(input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "options" argument must be of type Object. ' +
`Received type ${typeof input}`
});
@@ -411,7 +411,7 @@ assert.throws(
() => assert.strictEqual(new Error('foo'), new Error('foobar')),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: 'Expected "actual" to be reference-equal to "expected":\n' +
'+ actual - expected\n\n' +
'+ [Error: foo]\n- [Error: foobar]'
@@ -438,7 +438,7 @@ assert.throws(
() => assert(...[]),
{
message: 'No value argument passed to `assert.ok()`',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
generatedMessage: true
}
);
@@ -446,7 +446,7 @@ assert.throws(
() => a(),
{
message: 'No value argument passed to `assert.ok()`',
- name: 'AssertionError [ERR_ASSERTION]'
+ name: 'AssertionError'
}
);
@@ -886,7 +886,7 @@ common.expectsError(
() => assert.throws(errFn, errObj),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${start}\n${actExp}\n\n` +
' Comparison {\n' +
' code: 404,\n' +
@@ -903,7 +903,7 @@ common.expectsError(
() => assert.throws(errFn, errObj),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: `${start}\n${actExp}\n\n` +
' Comparison {\n' +
'+ code: 404,\n' +
@@ -938,7 +938,7 @@ common.expectsError(
assert.throws(
() => assert.throws(() => { throw new TypeError('e'); }, new Error('e')),
{
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
code: 'ERR_ASSERTION',
message: `${start}\n${actExp}\n\n` +
' Comparison {\n' +
@@ -951,7 +951,7 @@ common.expectsError(
assert.throws(
() => assert.throws(() => { throw new Error('foo'); }, new Error('')),
{
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
code: 'ERR_ASSERTION',
generatedMessage: true,
message: `${start}\n${actExp}\n\n` +
@@ -969,7 +969,7 @@ common.expectsError(
// eslint-disable-next-line no-throw-literal
() => a.doesNotThrow(() => { throw undefined; }),
{
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
code: 'ERR_ASSERTION',
message: 'Got unwanted exception.\nActual message: "undefined"'
}
@@ -1102,7 +1102,7 @@ assert.throws(
() => assert.strictEqual('test test', 'test foobar'),
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: strictEqualMessageStart +
'+ actual - expected\n\n' +
"+ 'test test'\n" +
@@ -1119,7 +1119,7 @@ assert.throws(
},
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: 'Expected "actual" not to be reference-equal to "expected": {}'
}
);
@@ -1131,7 +1131,7 @@ assert.throws(
},
{
code: 'ERR_ASSERTION',
- name: 'AssertionError [ERR_ASSERTION]',
+ name: 'AssertionError',
message: 'Expected "actual" not to be reference-equal to "expected":\n\n' +
'{\n a: true\n}\n'
}
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
index cc5692b24b..ddf2edd896 100644
--- a/test/parallel/test-buffer-alloc.js
+++ b/test/parallel/test-buffer-alloc.js
@@ -967,12 +967,12 @@ common.expectsError(
});
assert.throws(() => Buffer.from(), {
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The first argument must be one of type string, Buffer, ' +
'ArrayBuffer, Array, or Array-like Object. Received type undefined'
});
assert.throws(() => Buffer.from(null), {
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The first argument must be one of type string, Buffer, ' +
'ArrayBuffer, Array, or Array-like Object. Received type object'
});
diff --git a/test/parallel/test-buffer-arraybuffer.js b/test/parallel/test-buffer-arraybuffer.js
index 2a1ce14107..699d13e955 100644
--- a/test/parallel/test-buffer-arraybuffer.js
+++ b/test/parallel/test-buffer-arraybuffer.js
@@ -42,7 +42,7 @@ assert.throws(function() {
Buffer.from(new AB());
}, {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The first argument must be one of type string, Buffer,' +
' ArrayBuffer, Array, or Array-like Object. Received type object'
});
@@ -65,12 +65,12 @@ assert.throws(function() {
assert.throws(() => Buffer.from(ab.buffer, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: '"offset" is outside of buffer bounds'
});
assert.throws(() => Buffer.from(ab.buffer, 3, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: '"length" is outside of buffer bounds'
});
}
@@ -93,12 +93,12 @@ assert.throws(function() {
assert.throws(() => Buffer(ab.buffer, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: '"offset" is outside of buffer bounds'
});
assert.throws(() => Buffer(ab.buffer, 3, 6), {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: '"length" is outside of buffer bounds'
});
}
@@ -120,7 +120,7 @@ assert.throws(function() {
Buffer.from(ab, Infinity);
}, {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: '"offset" is outside of buffer bounds'
});
}
@@ -142,7 +142,7 @@ assert.throws(function() {
Buffer.from(ab, 0, Infinity);
}, {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: '"length" is outside of buffer bounds'
});
}
diff --git a/test/parallel/test-buffer-read.js b/test/parallel/test-buffer-read.js
index 7b3b9eb8e2..7ab04d3eb3 100644
--- a/test/parallel/test-buffer-read.js
+++ b/test/parallel/test-buffer-read.js
@@ -54,12 +54,12 @@ read(buf, 'readUIntLE', [2, 2], 0xea48);
// Error name and message
const OOR_ERROR =
{
- name: 'RangeError [ERR_OUT_OF_RANGE]'
+ name: 'RangeError'
};
const OOB_ERROR =
{
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
};
diff --git a/test/parallel/test-buffer-readdouble.js b/test/parallel/test-buffer-readdouble.js
index a61ab352c1..09556dc640 100644
--- a/test/parallel/test-buffer-readdouble.js
+++ b/test/parallel/test-buffer-readdouble.js
@@ -116,7 +116,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
() => buffer[fn](offset),
{
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 and <= 0. Received ${offset}`
});
@@ -126,7 +126,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
() => Buffer.alloc(1)[fn](1),
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
});
@@ -135,7 +135,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
() => buffer[fn](offset),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-buffer-readfloat.js b/test/parallel/test-buffer-readfloat.js
index e6bb779804..720b16462a 100644
--- a/test/parallel/test-buffer-readfloat.js
+++ b/test/parallel/test-buffer-readfloat.js
@@ -79,7 +79,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
() => buffer[fn](offset),
{
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 and <= 0. Received ${offset}`
});
@@ -89,7 +89,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
() => Buffer.alloc(1)[fn](1),
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
});
@@ -98,7 +98,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
() => buffer[fn](offset),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-buffer-readint.js b/test/parallel/test-buffer-readint.js
index 971dd3bb95..8758652b28 100644
--- a/test/parallel/test-buffer-readint.js
+++ b/test/parallel/test-buffer-readint.js
@@ -18,7 +18,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](o),
{
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),
{
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),
{
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 an integer. Received ${offset}`
});
@@ -152,7 +152,7 @@ const assert = require('assert');
() => buffer[fn](0, byteLength),
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}`
});
@@ -167,7 +167,7 @@ const assert = require('assert');
() => buffer[fn](o, i),
{
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),
{
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 and <= ${8 - i}. Received ${offset}`
});
@@ -187,7 +187,7 @@ const assert = require('assert');
() => buffer[fn](offset, i),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-buffer-readuint.js b/test/parallel/test-buffer-readuint.js
index f532febd0f..31e32bc3df 100644
--- a/test/parallel/test-buffer-readuint.js
+++ b/test/parallel/test-buffer-readuint.js
@@ -18,7 +18,7 @@ const assert = require('assert');
() => buffer[`read${fn}`](o),
{
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),
{
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),
{
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 an integer. Received ${offset}`
});
@@ -120,7 +120,7 @@ const assert = require('assert');
() => buffer[fn](0, byteLength),
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}`
});
@@ -135,7 +135,7 @@ const assert = require('assert');
() => buffer[fn](o, i),
{
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),
{
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 and <= ${8 - i}. Received ${offset}`
});
@@ -155,7 +155,7 @@ const assert = require('assert');
() => buffer[fn](offset, i),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-buffer-slow.js b/test/parallel/test-buffer-slow.js
index c9f5f17841..1dbc217bda 100644
--- a/test/parallel/test-buffer-slow.js
+++ b/test/parallel/test-buffer-slow.js
@@ -42,7 +42,7 @@ try {
// Should throw with invalid length type
const bufferInvalidTypeMsg = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: /^The "size" argument must be of type number/,
};
assert.throws(() => SlowBuffer(), bufferInvalidTypeMsg);
@@ -53,7 +53,7 @@ assert.throws(() => SlowBuffer(true), bufferInvalidTypeMsg);
// Should throw with invalid length value
const bufferMaxSizeMsg = {
code: 'ERR_INVALID_OPT_VALUE',
- name: 'RangeError [ERR_INVALID_OPT_VALUE]',
+ name: 'RangeError',
message: /^The value "[^"]*" is invalid for option "size"$/
};
assert.throws(() => SlowBuffer(NaN), bufferMaxSizeMsg);
diff --git a/test/parallel/test-buffer-writedouble.js b/test/parallel/test-buffer-writedouble.js
index 8a17d53690..4bb7fe7e56 100644
--- a/test/parallel/test-buffer-writedouble.js
+++ b/test/parallel/test-buffer-writedouble.js
@@ -98,7 +98,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
() => small[fn](11.11, 0),
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
});
@@ -113,7 +113,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
() => buffer[fn](23, offset),
{
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 and <= 8. Received ${offset}`
});
@@ -124,7 +124,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
() => buffer[fn](42, offset),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-buffer-writefloat.js b/test/parallel/test-buffer-writefloat.js
index 4c2c7539ea..cd198b01ef 100644
--- a/test/parallel/test-buffer-writefloat.js
+++ b/test/parallel/test-buffer-writefloat.js
@@ -80,7 +80,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
() => small[fn](11.11, 0),
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError [ERR_BUFFER_OUT_OF_BOUNDS]',
+ name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
});
@@ -96,7 +96,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
() => buffer[fn](23, offset),
{
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 and <= 4. Received ${offset}`
}
@@ -108,7 +108,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
() => buffer[fn](42, offset),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-buffer-writeint.js b/test/parallel/test-buffer-writeint.js
index 0e5b4960ab..7dba14211c 100644
--- a/test/parallel/test-buffer-writeint.js
+++ b/test/parallel/test-buffer-writeint.js
@@ -205,7 +205,7 @@ const errorOutOfBounds = common.expectsError({
() => data[fn](42, 0, byteLength),
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}`
});
@@ -223,7 +223,7 @@ const errorOutOfBounds = common.expectsError({
data[fn](val, 0, i);
}, {
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "value" is out of range. ' +
`It must be >= ${min} and <= ${max}. Received ${val}`
});
@@ -234,7 +234,7 @@ const errorOutOfBounds = common.expectsError({
() => data[fn](min, o, i),
{
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),
{
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 and <= ${8 - i}. Received ${offset}`
});
@@ -254,7 +254,7 @@ const errorOutOfBounds = common.expectsError({
() => data[fn](max, offset, i),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-buffer-writeuint.js b/test/parallel/test-buffer-writeuint.js
index 387aafd335..cd50000442 100644
--- a/test/parallel/test-buffer-writeuint.js
+++ b/test/parallel/test-buffer-writeuint.js
@@ -162,7 +162,7 @@ const assert = require('assert');
() => data[fn](42, 0, byteLength),
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "byteLength" is out of range. ' +
`It must be an integer. Received ${byteLength}`
});
@@ -176,7 +176,7 @@ const assert = require('assert');
data[fn](val, 0, i);
}, {
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "value" is out of range. ' +
`It must be >= 0 and <= ${val - 1}. Received ${val}`
});
@@ -186,7 +186,7 @@ const assert = require('assert');
() => data[fn](23, o, i),
{
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),
{
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 and <= ${8 - i}. Received ${offset}`
});
@@ -206,7 +206,7 @@ const assert = require('assert');
() => data[fn](val - 1, offset, i),
{
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 an integer. Received ${offset}`
});
diff --git a/test/parallel/test-child-process-fork.js b/test/parallel/test-child-process-fork.js
index 5fee2892f3..44d22ab211 100644
--- a/test/parallel/test-child-process-fork.js
+++ b/test/parallel/test-child-process-fork.js
@@ -39,18 +39,18 @@ n.on('message', (m) => {
// https://github.com/joyent/node/issues/2355 - JSON.stringify(undefined)
// returns "undefined" but JSON.parse() cannot parse that...
assert.throws(() => n.send(undefined), {
- name: 'TypeError [ERR_MISSING_ARGS]',
+ name: 'TypeError',
message: 'The "message" argument must be specified',
code: 'ERR_MISSING_ARGS'
});
assert.throws(() => n.send(), {
- name: 'TypeError [ERR_MISSING_ARGS]',
+ name: 'TypeError',
message: 'The "message" argument must be specified',
code: 'ERR_MISSING_ARGS'
});
assert.throws(() => n.send(Symbol()), {
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "message" argument must be one of type string,' +
' object, number, or boolean. Received type symbol',
code: 'ERR_INVALID_ARG_TYPE'
diff --git a/test/parallel/test-crypto-pbkdf2.js b/test/parallel/test-crypto-pbkdf2.js
index db12cf14fc..4e3c4f64f0 100644
--- a/test/parallel/test-crypto-pbkdf2.js
+++ b/test/parallel/test-crypto-pbkdf2.js
@@ -64,7 +64,7 @@ assert.throws(
() => crypto.pbkdf2('password', 'salt', 1, 20, null),
{
code: 'ERR_INVALID_CALLBACK',
- name: 'TypeError [ERR_INVALID_CALLBACK]'
+ name: 'TypeError'
}
);
@@ -72,7 +72,7 @@ assert.throws(
() => crypto.pbkdf2Sync('password', 'salt', -1, 20, 'sha1'),
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "iterations" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1'
}
@@ -84,7 +84,7 @@ assert.throws(
crypto.pbkdf2Sync('password', 'salt', 1, notNumber, 'sha256');
}, {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "keylen" argument must be of type number. ' +
`Received type ${typeof notNumber}`
});
@@ -97,7 +97,7 @@ assert.throws(
common.mustNotCall());
}, {
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "keylen" is out of range. It ' +
`must be an integer. Received ${input}`
});
@@ -110,7 +110,7 @@ assert.throws(
common.mustNotCall());
}, {
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "keylen" is out of range. It ' +
`must be >= 0 && < 4294967296. Received ${input}`
});
@@ -124,7 +124,7 @@ assert.throws(
() => crypto.pbkdf2('password', 'salt', 8, 8, common.mustNotCall()),
{
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. ' +
'Received type undefined'
});
@@ -133,7 +133,7 @@ assert.throws(
() => crypto.pbkdf2Sync('password', 'salt', 8, 8),
{
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. ' +
'Received type undefined'
});
@@ -145,7 +145,7 @@ assert.throws(
() => crypto.pbkdf2(input, 'salt', 8, 8, 'sha256', common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
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()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: `The "salt" argument must be one of type string, ${msgPart2}`
}
);
@@ -163,7 +163,7 @@ assert.throws(
() => crypto.pbkdf2Sync(input, 'salt', 8, 8, 'sha256'),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: `The "password" argument must be one of type string, ${msgPart2}`
}
);
@@ -172,7 +172,7 @@ assert.throws(
() => crypto.pbkdf2Sync('pass', input, 8, 8, 'sha256'),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
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()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: `The "iterations" argument must be of type number. ${received}`
}
);
@@ -193,7 +193,7 @@ assert.throws(
() => crypto.pbkdf2Sync('pass', 'salt', i, 8, 'sha256'),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
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()),
{
code: 'ERR_CRYPTO_INVALID_DIGEST',
- name: 'TypeError [ERR_CRYPTO_INVALID_DIGEST]',
+ name: 'TypeError',
message: 'Invalid digest: md55'
}
);
@@ -235,7 +235,7 @@ assert.throws(
() => crypto.pbkdf2Sync('pass', 'salt', 8, 8, 'md55'),
{
code: 'ERR_CRYPTO_INVALID_DIGEST',
- name: 'TypeError [ERR_CRYPTO_INVALID_DIGEST]',
+ name: 'TypeError',
message: 'Invalid digest: md55'
}
);
diff --git a/test/parallel/test-crypto-random.js b/test/parallel/test-crypto-random.js
index deacb45e8f..668607b439 100644
--- a/test/parallel/test-crypto-random.js
+++ b/test/parallel/test-crypto-random.js
@@ -44,7 +44,7 @@ common.expectWarning('DeprecationWarning',
[undefined, null, false, true, {}, []].forEach((value) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "size" argument must be of type number. ' +
`Received type ${typeof value}`
};
@@ -55,7 +55,7 @@ common.expectWarning('DeprecationWarning',
[-1, NaN, 2 ** 32].forEach((value) => {
const errObj = {
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 && <= ' +
`${kMaxPossibleLength}. Received ${value}`
};
@@ -199,7 +199,7 @@ common.expectWarning('DeprecationWarning',
const typeErrObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "offset" argument must be of type number. ' +
'Received type string'
};
@@ -222,7 +222,7 @@ common.expectWarning('DeprecationWarning',
[NaN, kMaxPossibleLength + 1, -10, (-1 >>> 0) + 1].forEach((offsetSize) => {
const errObj = {
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 && <= 10. Received ${offsetSize}`
};
@@ -245,7 +245,7 @@ common.expectWarning('DeprecationWarning',
const rangeErrObj = {
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "size + offset" is out of range. ' +
'It must be <= 10. Received 11'
};
@@ -265,7 +265,7 @@ assert.throws(
() => crypto.randomBytes((-1 >>> 0) + 1),
{
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 && <= ${kMaxPossibleLength}. Received 4294967296`
}
diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js
index da4e8aa331..ca7f2986e1 100644
--- a/test/parallel/test-crypto-sign-verify.js
+++ b/test/parallel/test-crypto-sign-verify.js
@@ -323,7 +323,7 @@ common.expectsError(
const type = typeof input;
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "algorithm" argument must be of type string. ' +
`Received type ${type}`
};
@@ -350,7 +350,7 @@ common.expectsError(
const type = typeof input;
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "key" argument must be one of type string, Buffer, ' +
`TypedArray, DataView, or KeyObject. Received type ${type}`
};
diff --git a/test/parallel/test-dgram-send-address-types.js b/test/parallel/test-dgram-send-address-types.js
index 0d208cfdc8..7f4bcf53eb 100644
--- a/test/parallel/test-dgram-send-address-types.js
+++ b/test/parallel/test-dgram-send-address-types.js
@@ -25,7 +25,7 @@ const client = dgram.createSocket('udp4').bind(0, () => {
[[], 1, true].forEach((invalidInput) => {
const expectedError = {
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. ' +
`Received type ${typeof invalidInput}`
};
diff --git a/test/parallel/test-dgram-sendto.js b/test/parallel/test-dgram-sendto.js
index 3922ccbb64..6eea4894b1 100644
--- a/test/parallel/test-dgram-sendto.js
+++ b/test/parallel/test-dgram-sendto.js
@@ -6,7 +6,7 @@ const socket = dgram.createSocket('udp4');
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "offset" argument must be of type number. Received type ' +
'undefined'
};
diff --git a/test/parallel/test-dns-setservers-type-check.js b/test/parallel/test-dns-setservers-type-check.js
index 256c029427..bdf52a32e0 100644
--- a/test/parallel/test-dns-setservers-type-check.js
+++ b/test/parallel/test-dns-setservers-type-check.js
@@ -19,7 +19,7 @@ const promiseResolver = new dns.promises.Resolver();
].forEach((val) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "servers" argument must be of type Array. Received type ' +
typeof val
};
@@ -59,7 +59,7 @@ const promiseResolver = new dns.promises.Resolver();
].forEach((val) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "servers[0]" argument must be of type string. ' +
`Received type ${typeof val[0]}`
};
diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js
index b96055ba4d..f974c2afa6 100644
--- a/test/parallel/test-dns.js
+++ b/test/parallel/test-dns.js
@@ -81,7 +81,7 @@ assert(existing.length > 0);
dns.setServers([serv]);
},
{
- name: 'TypeError [ERR_INVALID_IP_ADDRESS]',
+ name: 'TypeError',
code: 'ERR_INVALID_IP_ADDRESS'
}
);
diff --git a/test/parallel/test-error-serdes.js b/test/parallel/test-error-serdes.js
index e9d91e5736..908e81977b 100644
--- a/test/parallel/test-error-serdes.js
+++ b/test/parallel/test-error-serdes.js
@@ -41,6 +41,6 @@ assert.strictEqual(cycle(Function), '[Function: Function]');
{
const err = new ERR_INVALID_ARG_TYPE('object', 'Object', 42);
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');
}
diff --git a/test/parallel/test-errors-systemerror.js b/test/parallel/test-errors-systemerror.js
index 0b5f9b9a10..e801871f40 100644
--- a/test/parallel/test-errors-systemerror.js
+++ b/test/parallel/test-errors-systemerror.js
@@ -6,7 +6,7 @@ const assert = require('assert');
const { E, SystemError, codes } = require('internal/errors');
assert.throws(
- () => { throw new SystemError(); },
+ () => { new SystemError(); },
{
name: 'TypeError',
message: 'Cannot read property \'match\' of undefined'
@@ -29,7 +29,7 @@ const { ERR_TEST } = codes;
() => { throw new ERR_TEST(ctx); },
{
code: 'ERR_TEST',
- name: 'SystemError [ERR_TEST]',
+ name: 'SystemError',
message: 'custom message: syscall_test returned ETEST (code message)' +
' /str => /str2',
info: ctx
@@ -49,7 +49,7 @@ const { ERR_TEST } = codes;
() => { throw new ERR_TEST(ctx); },
{
code: 'ERR_TEST',
- name: 'SystemError [ERR_TEST]',
+ name: 'SystemError',
message: 'custom message: syscall_test returned ETEST (code message)' +
' /buf => /str2',
info: ctx
@@ -69,7 +69,7 @@ const { ERR_TEST } = codes;
() => { throw new ERR_TEST(ctx); },
{
code: 'ERR_TEST',
- name: 'SystemError [ERR_TEST]',
+ name: 'SystemError',
message: 'custom message: syscall_test returned ETEST (code message)' +
' /buf => /buf2',
info: ctx
@@ -121,12 +121,12 @@ const { ERR_TEST } = codes;
assert.throws(
() => {
const err = new ERR_TEST(ctx);
- err.name = 'SystemError [CUSTOM_ERR_TEST]';
+ err.name = 'Foobar';
throw err;
},
{
code: 'ERR_TEST',
- name: 'SystemError [CUSTOM_ERR_TEST]',
+ name: 'Foobar',
message: 'custom message: syscall_test returned ERR_TEST ' +
'(Error occurred)',
info: ctx
diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js
index 81a117f771..cc8caf86fd 100644
--- a/test/parallel/test-fs-chmod.js
+++ b/test/parallel/test-fs-chmod.js
@@ -150,7 +150,7 @@ if (fs.lchmod) {
[false, 1, {}, [], null, undefined].forEach((input) => {
const errObj = {
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.' +
` Received type ${typeof input}`
};
diff --git a/test/parallel/test-fs-close-errors.js b/test/parallel/test-fs-close-errors.js
index 48af5eb485..42d990410f 100644
--- a/test/parallel/test-fs-close-errors.js
+++ b/test/parallel/test-fs-close-errors.js
@@ -10,7 +10,7 @@ const fs = require('fs');
['', false, null, undefined, {}, []].forEach((input) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof input}`
};
diff --git a/test/parallel/test-fs-fchmod.js b/test/parallel/test-fs-fchmod.js
index 06f4c0b272..ebbc2792e1 100644
--- a/test/parallel/test-fs-fchmod.js
+++ b/test/parallel/test-fs-fchmod.js
@@ -11,7 +11,7 @@ const fs = require('fs');
[false, null, undefined, {}, [], ''].forEach((input) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. Received type ' +
typeof input
};
@@ -23,7 +23,7 @@ const fs = require('fs');
[false, null, undefined, {}, [], '', '123x'].forEach((input) => {
const errObj = {
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 ' +
`octal string. Received ${util.inspect(input)}`
};
@@ -34,7 +34,7 @@ const fs = require('fs');
[-1, 2 ** 32].forEach((input) => {
const errObj = {
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 && <= ' +
`2147483647. Received ${input}`
};
@@ -45,7 +45,7 @@ const fs = require('fs');
[-1, 2 ** 32].forEach((input) => {
const errObj = {
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 && <= ' +
`4294967295. Received ${input}`
};
@@ -57,7 +57,7 @@ const fs = require('fs');
[NaN, Infinity].forEach((input) => {
const errObj = {
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. ' +
`Received ${input}`
};
@@ -71,7 +71,7 @@ const fs = require('fs');
[1.5].forEach((input) => {
const errObj = {
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. ' +
`Received ${input}`
};
diff --git a/test/parallel/test-fs-fchown.js b/test/parallel/test-fs-fchown.js
index 500c06a47c..832dd071ea 100644
--- a/test/parallel/test-fs-fchown.js
+++ b/test/parallel/test-fs-fchown.js
@@ -18,7 +18,7 @@ function test(input, errObj) {
['', false, null, undefined, {}, []].forEach((input) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. Received type ' +
typeof input
};
@@ -28,7 +28,7 @@ function test(input, errObj) {
[Infinity, NaN].forEach((input) => {
const errObj = {
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. ' +
`Received ${input}`
};
@@ -38,7 +38,7 @@ function test(input, errObj) {
[-1, 2 ** 32].forEach((input) => {
const errObj = {
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 && < 4294967296. Received ${input}`
};
diff --git a/test/parallel/test-fs-fsync.js b/test/parallel/test-fs-fsync.js
index 4d96091f34..cf80f46bd0 100644
--- a/test/parallel/test-fs-fsync.js
+++ b/test/parallel/test-fs-fsync.js
@@ -53,7 +53,7 @@ fs.open(fileTemp, 'a', 0o777, common.mustCall(function(err, fd) {
['', false, null, undefined, {}, []].forEach((input) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. Received type ' +
typeof input
};
diff --git a/test/parallel/test-fs-lchmod.js b/test/parallel/test-fs-lchmod.js
index e84fa08aac..3b5a51becd 100644
--- a/test/parallel/test-fs-lchmod.js
+++ b/test/parallel/test-fs-lchmod.js
@@ -41,7 +41,7 @@ assert.throws(() => fs.lchmod(f, {}), { code: 'ERR_INVALID_CALLBACK' });
[false, null, undefined, {}, [], '', '123x'].forEach((input) => {
const errObj = {
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 ' +
`octal string. Received ${util.inspect(input)}`
};
@@ -53,7 +53,7 @@ assert.throws(() => fs.lchmod(f, {}), { code: 'ERR_INVALID_CALLBACK' });
[-1, 2 ** 32].forEach((input) => {
const errObj = {
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 && <= ' +
`4294967295. Received ${input}`
};
diff --git a/test/parallel/test-fs-open.js b/test/parallel/test-fs-open.js
index 79b78ff2ef..51cd9ecf31 100644
--- a/test/parallel/test-fs-open.js
+++ b/test/parallel/test-fs-open.js
@@ -102,7 +102,7 @@ for (const extra of [[], ['r'], ['r', 0], ['r', 0, 'bad callback']]) {
fs.promises.open(i, 'r'),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]'
+ name: 'TypeError'
}
);
});
diff --git a/test/parallel/test-fs-promises.js b/test/parallel/test-fs-promises.js
index 97b5f8326e..2e6ba0e8a2 100644
--- a/test/parallel/test-fs-promises.js
+++ b/test/parallel/test-fs-promises.js
@@ -164,7 +164,7 @@ async function getHandle(dest) {
},
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "gid" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1'
});
@@ -175,7 +175,7 @@ async function getHandle(dest) {
},
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "gid" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1'
});
@@ -336,7 +336,7 @@ async function getHandle(dest) {
async () => mkdir(dir, { recursive }),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "recursive" argument must be of type boolean. ' +
`Received type ${typeof recursive}`
}
@@ -352,7 +352,7 @@ async function getHandle(dest) {
async () => mkdtemp(1),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]'
+ name: 'TypeError'
}
);
}
diff --git a/test/parallel/test-fs-read-type.js b/test/parallel/test-fs-read-type.js
index d75464ce0a..b51df51589 100644
--- a/test/parallel/test-fs-read-type.js
+++ b/test/parallel/test-fs-read-type.js
@@ -14,7 +14,7 @@ assert.throws(
() => fs.read(fd, expected.length, 0, 'utf-8', common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "buffer" argument must be one of type Buffer, TypedArray, ' +
'or DataView. Received type number'
}
@@ -30,7 +30,7 @@ assert.throws(
common.mustNotCall());
}, {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof value}`
});
@@ -45,7 +45,7 @@ assert.throws(() => {
common.mustNotCall());
}, {
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. ' +
'Received -1'
});
@@ -59,7 +59,7 @@ assert.throws(() => {
common.mustNotCall());
}, {
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "length" is out of range. ' +
'It must be >= 0 && <= 4. Received -1'
});
@@ -69,7 +69,7 @@ assert.throws(
() => fs.readSync(fd, expected.length, 0, 'utf-8'),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "buffer" argument must be one of type Buffer, TypedArray, ' +
'or DataView. Received type number'
}
@@ -84,7 +84,7 @@ assert.throws(
0);
}, {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof value}`
});
@@ -98,7 +98,7 @@ assert.throws(() => {
0);
}, {
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. Received -1'
});
@@ -111,7 +111,7 @@ assert.throws(() => {
0);
}, {
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "length" is out of range. ' +
'It must be >= 0 && <= 4. Received -1'
});
diff --git a/test/parallel/test-fs-rename-type-check.js b/test/parallel/test-fs-rename-type-check.js
index b8f0549f0c..bc1277740f 100644
--- a/test/parallel/test-fs-rename-type-check.js
+++ b/test/parallel/test-fs-rename-type-check.js
@@ -10,7 +10,7 @@ const fs = require('fs');
() => fs.rename(input, 'does-not-exist', common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: `The "oldPath" argument must be one ${type}`
}
);
@@ -18,7 +18,7 @@ const fs = require('fs');
() => fs.rename('does-not-exist', input, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: `The "newPath" argument must be one ${type}`
}
);
@@ -26,7 +26,7 @@ const fs = require('fs');
() => fs.renameSync(input, 'does-not-exist'),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: `The "oldPath" argument must be one ${type}`
}
);
@@ -34,7 +34,7 @@ const fs = require('fs');
() => fs.renameSync('does-not-exist', input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: `The "newPath" argument must be one ${type}`
}
);
diff --git a/test/parallel/test-fs-stat.js b/test/parallel/test-fs-stat.js
index a44e2ce3a7..40a0640724 100644
--- a/test/parallel/test-fs-stat.js
+++ b/test/parallel/test-fs-stat.js
@@ -134,7 +134,7 @@ fs.stat(__filename, common.mustCall(function(err, s) {
() => fs[fnName](input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof input}`
}
@@ -147,28 +147,28 @@ fs.stat(__filename, common.mustCall(function(err, s) {
() => fs.lstat(input, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]'
+ name: 'TypeError'
}
);
assert.throws(
() => fs.lstatSync(input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]'
+ name: 'TypeError'
}
);
assert.throws(
() => fs.stat(input, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]'
+ name: 'TypeError'
}
);
assert.throws(
() => fs.statSync(input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]'
+ name: 'TypeError'
}
);
});
diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js
index ddcf7a63ff..a600110319 100644
--- a/test/parallel/test-fs-symlink.js
+++ b/test/parallel/test-fs-symlink.js
@@ -61,7 +61,7 @@ fs.symlink(linkData, linkPath, common.mustCall(function(err) {
[false, 1, {}, [], null, undefined].forEach((input) => {
const errObj = {
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 ' +
`URL. Received type ${typeof input}`
};
@@ -75,7 +75,7 @@ fs.symlink(linkData, linkPath, common.mustCall(function(err) {
const errObj = {
code: 'ERR_FS_INVALID_SYMLINK_TYPE',
- name: 'Error [ERR_FS_INVALID_SYMLINK_TYPE]',
+ name: 'Error',
message:
'Symlink type must be one of "dir", "file", or "junction". Received "🍏"'
};
diff --git a/test/parallel/test-fs-truncate.js b/test/parallel/test-fs-truncate.js
index d1d743eb57..95036dc9f5 100644
--- a/test/parallel/test-fs-truncate.js
+++ b/test/parallel/test-fs-truncate.js
@@ -183,7 +183,7 @@ function testFtruncate(cb) {
() => fs.truncate(file5, input, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "len" argument must be of type number. ' +
`Received type ${typeof input}`
}
@@ -193,7 +193,7 @@ function testFtruncate(cb) {
() => fs.ftruncate(fd, input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "len" argument must be of type number. ' +
`Received type ${typeof input}`
}
@@ -205,7 +205,7 @@ function testFtruncate(cb) {
() => fs.truncate(file5, input),
{
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 ' +
`an integer. Received ${input}`
}
@@ -215,7 +215,7 @@ function testFtruncate(cb) {
() => fs.ftruncate(fd, input),
{
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 ' +
`an integer. Received ${input}`
}
@@ -267,7 +267,7 @@ function testFtruncate(cb) {
() => fs.truncate('/foo/bar', input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "len" argument must be of type number. ' +
`Received type ${typeof input}`
}
@@ -280,7 +280,7 @@ function testFtruncate(cb) {
() => fs[fnName](input),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "fd" argument must be of type number. ' +
`Received type ${typeof input}`
}
diff --git a/test/parallel/test-http-res-write-end-dont-take-array.js b/test/parallel/test-http-res-write-end-dont-take-array.js
index f801da246e..d7000f6fd2 100644
--- a/test/parallel/test-http-res-write-end-dont-take-array.js
+++ b/test/parallel/test-http-res-write-end-dont-take-array.js
@@ -37,7 +37,7 @@ server.once('request', common.mustCall((req, res) => {
const expectedError = {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
};
// Write should not accept an Array
diff --git a/test/parallel/test-http2-altsvc.js b/test/parallel/test-http2-altsvc.js
index 8b2e5b4690..3a1a1cf629 100644
--- a/test/parallel/test-http2-altsvc.js
+++ b/test/parallel/test-http2-altsvc.js
@@ -33,7 +33,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc('h2=":8000"', input),
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "originOrStream" is out of ' +
`range. It must be > 0 && < 4294967296. Received ${input}`
}
@@ -46,7 +46,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc(input),
{
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),
{
code: 'ERR_INVALID_CHAR',
- name: 'TypeError [ERR_INVALID_CHAR]',
+ name: 'TypeError',
message: 'Invalid character in alt'
}
);
@@ -67,7 +67,7 @@ server.on('session', common.mustCall((session) => {
() => session.altsvc('clear', input),
{
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),
{
code: 'ERR_HTTP2_ALTSVC_INVALID_ORIGIN',
- name: 'TypeError [ERR_HTTP2_ALTSVC_INVALID_ORIGIN]',
+ name: 'TypeError',
message: 'HTTP/2 ALTSVC frames require a valid origin'
}
);
@@ -96,7 +96,7 @@ server.on('session', common.mustCall((session) => {
},
{
code: 'ERR_HTTP2_ALTSVC_LENGTH',
- name: 'TypeError [ERR_HTTP2_ALTSVC_LENGTH]',
+ name: 'TypeError',
message: 'HTTP/2 ALTSVC frames are limited to 16382 bytes'
}
);
diff --git a/test/parallel/test-http2-client-http1-server.js b/test/parallel/test-http2-client-http1-server.js
index c7535adcef..2728033d19 100644
--- a/test/parallel/test-http2-client-http1-server.js
+++ b/test/parallel/test-http2-client-http1-server.js
@@ -27,7 +27,7 @@ server.listen(0, common.mustCall(() => {
client.on('error', common.expectsError({
code: 'ERR_HTTP2_ERROR',
type: NghttpError,
- name: 'Error [ERR_HTTP2_ERROR]',
+ name: 'Error',
message: 'Protocol error'
}));
diff --git a/test/parallel/test-http2-client-onconnect-errors.js b/test/parallel/test-http2-client-onconnect-errors.js
index 5c08478784..b00c050724 100644
--- a/test/parallel/test-http2-client-onconnect-errors.js
+++ b/test/parallel/test-http2-client-onconnect-errors.js
@@ -55,7 +55,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: {
code: 'ERR_HTTP2_ERROR',
type: NghttpError,
- name: 'Error [ERR_HTTP2_ERROR]',
+ name: 'Error',
message: nghttp2ErrorString(constants[key])
},
type: 'session'
diff --git a/test/parallel/test-http2-client-rststream-before-connect.js b/test/parallel/test-http2-client-rststream-before-connect.js
index 33e22130aa..8c3eb9bec3 100644
--- a/test/parallel/test-http2-client-rststream-before-connect.js
+++ b/test/parallel/test-http2-client-rststream-before-connect.js
@@ -21,7 +21,7 @@ server.listen(0, common.mustCall(() => {
assert.throws(
() => req.close(2 ** 32),
{
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
code: 'ERR_OUT_OF_RANGE',
message: 'The value of "code" is out of range. It must be ' +
'>= 0 && <= 4294967295. Received 4294967296'
diff --git a/test/parallel/test-http2-compat-serverrequest-headers.js b/test/parallel/test-http2-compat-serverrequest-headers.js
index bd46b71900..8b38ab147f 100644
--- a/test/parallel/test-http2-compat-serverrequest-headers.js
+++ b/test/parallel/test-http2-compat-serverrequest-headers.js
@@ -49,7 +49,7 @@ server.listen(0, common.mustCall(function() {
() => request.method = ' ',
{
code: 'ERR_INVALID_ARG_VALUE',
- name: 'TypeError [ERR_INVALID_ARG_VALUE]',
+ name: 'TypeError',
message: "The argument 'method' is invalid. Received ' '"
}
);
@@ -57,7 +57,7 @@ server.listen(0, common.mustCall(function() {
() => request.method = true,
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "method" argument must be of type string. ' +
'Received type boolean'
}
diff --git a/test/parallel/test-http2-compat-serverresponse-headers.js b/test/parallel/test-http2-compat-serverresponse-headers.js
index 94f1d19373..c47de48b6a 100644
--- a/test/parallel/test-http2-compat-serverresponse-headers.js
+++ b/test/parallel/test-http2-compat-serverresponse-headers.js
@@ -46,7 +46,7 @@ server.listen(0, common.mustCall(function() {
() => response[fnName](),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "name" argument must be of type string. Received ' +
'type undefined'
}
diff --git a/test/parallel/test-http2-createsecureserver-nooptions.js b/test/parallel/test-http2-createsecureserver-nooptions.js
index 767797febc..22a7562388 100644
--- a/test/parallel/test-http2-createsecureserver-nooptions.js
+++ b/test/parallel/test-http2-createsecureserver-nooptions.js
@@ -13,7 +13,7 @@ invalidOptions.forEach((invalidOption) => {
assert.throws(
() => http2.createSecureServer(invalidOption),
{
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
code: 'ERR_INVALID_ARG_TYPE',
message: 'The "options" argument must be of type Object. Received ' +
`type ${typeof invalidOption}`
diff --git a/test/parallel/test-http2-info-headers-errors.js b/test/parallel/test-http2-info-headers-errors.js
index a55e9df026..a2e17abd74 100644
--- a/test/parallel/test-http2-info-headers-errors.js
+++ b/test/parallel/test-http2-info-headers-errors.js
@@ -28,7 +28,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: {
code: 'ERR_HTTP2_ERROR',
type: NghttpError,
- name: 'Error [ERR_HTTP2_ERROR]',
+ name: 'Error',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
diff --git a/test/parallel/test-http2-origin.js b/test/parallel/test-http2-origin.js
index b06d371e29..d0d8c81f80 100644
--- a/test/parallel/test-http2-origin.js
+++ b/test/parallel/test-http2-origin.js
@@ -46,7 +46,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
() => session.origin(input),
{
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),
{
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),
{
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),
{
code: 'ERR_HTTP2_ORIGIN_LENGTH',
- name: 'TypeError [ERR_HTTP2_ORIGIN_LENGTH]'
+ name: 'TypeError'
}
);
}));
diff --git a/test/parallel/test-http2-respond-nghttperrors.js b/test/parallel/test-http2-respond-nghttperrors.js
index 3bdfbffeec..30d20d4b81 100644
--- a/test/parallel/test-http2-respond-nghttperrors.js
+++ b/test/parallel/test-http2-respond-nghttperrors.js
@@ -29,7 +29,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: {
code: 'ERR_HTTP2_ERROR',
type: NghttpError,
- name: 'Error [ERR_HTTP2_ERROR]',
+ name: 'Error',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
diff --git a/test/parallel/test-http2-respond-with-fd-errors.js b/test/parallel/test-http2-respond-with-fd-errors.js
index 4e876c532f..00ed777df5 100644
--- a/test/parallel/test-http2-respond-with-fd-errors.js
+++ b/test/parallel/test-http2-respond-with-fd-errors.js
@@ -36,7 +36,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: {
code: 'ERR_HTTP2_ERROR',
type: NghttpError,
- name: 'Error [ERR_HTTP2_ERROR]',
+ name: 'Error',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
diff --git a/test/parallel/test-http2-server-push-stream-errors-args.js b/test/parallel/test-http2-server-push-stream-errors-args.js
index 24f7c9fcef..0c3b9dcfcc 100644
--- a/test/parallel/test-http2-server-push-stream-errors-args.js
+++ b/test/parallel/test-http2-server-push-stream-errors-args.js
@@ -31,7 +31,7 @@ server.on('stream', common.mustCall((stream, headers) => {
() => stream.pushStream({ 'connection': 'test' }, {}, () => {}),
{
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
- name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
+ name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: "connection"'
}
);
diff --git a/test/parallel/test-http2-server-push-stream-errors.js b/test/parallel/test-http2-server-push-stream-errors.js
index 35d8b796e4..b1c5421310 100644
--- a/test/parallel/test-http2-server-push-stream-errors.js
+++ b/test/parallel/test-http2-server-push-stream-errors.js
@@ -53,7 +53,7 @@ const genericTests = Object.getOwnPropertyNames(constants)
error: {
code: 'ERR_HTTP2_ERROR',
type: NghttpError,
- name: 'Error [ERR_HTTP2_ERROR]',
+ name: 'Error',
message: nghttp2ErrorString(constants[key])
},
type: 'stream'
diff --git a/test/parallel/test-http2-util-headers-list.js b/test/parallel/test-http2-util-headers-list.js
index 2814613df2..5045263b15 100644
--- a/test/parallel/test-http2-util-headers-list.js
+++ b/test/parallel/test-http2-util-headers-list.js
@@ -283,7 +283,7 @@ const {
].forEach((name) => {
common.expectsError(() => mapToHeaders({ [name]: 'abc' }), {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
- name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
+ name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${name.toLowerCase()}"`
});
@@ -291,7 +291,7 @@ const {
common.expectsError(() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }), {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
- name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
+ name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"`
});
@@ -299,7 +299,7 @@ common.expectsError(() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }), {
common.expectsError(
() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] }), {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
- name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
+ name: 'TypeError',
message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"`
});
diff --git a/test/parallel/test-https-options-boolean-check.js b/test/parallel/test-https-options-boolean-check.js
index bed5fb0325..295082e1ce 100644
--- a/test/parallel/test-https-options-boolean-check.js
+++ b/test/parallel/test-https-options-boolean-check.js
@@ -87,7 +87,7 @@ const caArrDataView = toDataView(caCert);
https.createServer({ key, cert });
}, {
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, ' +
`TypedArray, or DataView. Received type ${type}`
});
@@ -112,7 +112,7 @@ const caArrDataView = toDataView(caCert);
https.createServer({ key, cert });
}, {
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,' +
` TypedArray, or DataView. Received type ${type}`
});
@@ -146,7 +146,7 @@ const caArrDataView = toDataView(caCert);
https.createServer({ key, cert, ca });
}, {
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, ' +
`TypedArray, or DataView. Received type ${type}`
});
diff --git a/test/parallel/test-internal-error-original-names.js b/test/parallel/test-internal-error-original-names.js
index 195e39b199..e00221b1a6 100644
--- a/test/parallel/test-internal-error-original-names.js
+++ b/test/parallel/test-internal-error-original-names.js
@@ -17,7 +17,7 @@ errors.E('TEST_ERROR_1', 'Error for testing purposes: %s',
{
const err = new errors.codes.TEST_ERROR_1('test');
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;
const err = new errors.codes.TEST_ERROR_1('test');
assert(err instanceof Error);
- assert.strictEqual(err.name, 'Error [TEST_ERROR_1]');
+ assert.strictEqual(err.name, 'Error');
}
diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js
index bf1983f3b3..53fbf06c77 100644
--- a/test/parallel/test-internal-errors.js
+++ b/test/parallel/test-internal-errors.js
@@ -20,7 +20,7 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
{
const err = new errors.codes.TEST_ERROR_1('test');
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.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');
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.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');
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.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');
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.code, 'TEST_ERROR_2');
}
@@ -79,27 +79,6 @@ common.expectsError(() => {
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
// name.
{
@@ -113,7 +92,7 @@ common.expectsError(() => {
assert.strictEqual(myError.code, 'FHQWHGADS');
assert.strictEqual(myError.name, initialName);
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'));
}
diff --git a/test/parallel/test-next-tick-errors.js b/test/parallel/test-next-tick-errors.js
index acb7c49727..51ed2524a0 100644
--- a/test/parallel/test-next-tick-errors.js
+++ b/test/parallel/test-next-tick-errors.js
@@ -48,7 +48,7 @@ function testNextTickWith(val) {
},
{
code: 'ERR_INVALID_CALLBACK',
- name: 'TypeError [ERR_INVALID_CALLBACK]',
+ name: 'TypeError',
type: TypeError
}
);
diff --git a/test/parallel/test-process-cpuUsage.js b/test/parallel/test-process-cpuUsage.js
index 0b1d53978c..76e0702b9e 100644
--- a/test/parallel/test-process-cpuUsage.js
+++ b/test/parallel/test-process-cpuUsage.js
@@ -37,7 +37,7 @@ assert.throws(
() => process.cpuUsage(1),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "prevValue" argument must be of type object. ' +
'Received type number'
}
@@ -53,7 +53,7 @@ assert.throws(
() => process.cpuUsage(value),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "prevValue.user" property must be of type number. ' +
`Received type ${typeof value.user}`
}
@@ -68,7 +68,7 @@ assert.throws(
() => process.cpuUsage(value),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "prevValue.system" property must be of type number. ' +
`Received type ${typeof value.system}`
}
@@ -84,7 +84,7 @@ assert.throws(
() => process.cpuUsage(value),
{
code: 'ERR_INVALID_OPT_VALUE',
- name: 'RangeError [ERR_INVALID_OPT_VALUE]',
+ name: 'RangeError',
message: `The value "${value.user}" is invalid ` +
'for option "prevValue.user"'
}
@@ -99,7 +99,7 @@ assert.throws(
() => process.cpuUsage(value),
{
code: 'ERR_INVALID_OPT_VALUE',
- name: 'RangeError [ERR_INVALID_OPT_VALUE]',
+ name: 'RangeError',
message: `The value "${value.system}" is invalid ` +
'for option "prevValue.system"'
}
diff --git a/test/parallel/test-process-initgroups.js b/test/parallel/test-process-initgroups.js
index f5e839b1d2..0cc0760d76 100644
--- a/test/parallel/test-process-initgroups.js
+++ b/test/parallel/test-process-initgroups.js
@@ -17,7 +17,7 @@ if (!common.isMainThread)
},
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message:
'The "user" argument must be ' +
'one of type number or string. ' +
@@ -33,7 +33,7 @@ if (!common.isMainThread)
},
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message:
'The "extraGroup" argument must be ' +
'one of type number or string. ' +
diff --git a/test/parallel/test-process-kill-pid.js b/test/parallel/test-process-kill-pid.js
index c299ceabaa..698fa4cf62 100644
--- a/test/parallel/test-process-kill-pid.js
+++ b/test/parallel/test-process-kill-pid.js
@@ -41,7 +41,7 @@ const assert = require('assert');
['SIGTERM', null, undefined, NaN, Infinity, -Infinity].forEach((val) => {
assert.throws(() => process.kill(val), {
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "pid" argument must be of type number. ' +
`Received type ${typeof val}`
});
diff --git a/test/parallel/test-process-setgroups.js b/test/parallel/test-process-setgroups.js
index 74de3e7a25..31e56a2da3 100644
--- a/test/parallel/test-process-setgroups.js
+++ b/test/parallel/test-process-setgroups.js
@@ -16,7 +16,7 @@ assert.throws(
},
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "groups" argument must be of type Array. ' +
'Received type undefined'
}
@@ -28,7 +28,7 @@ assert.throws(
},
{
code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError [ERR_OUT_OF_RANGE]',
+ name: 'RangeError',
message: 'The value of "groups[1]" is out of range. ' +
'It must be >= 0 && < 4294967296. Received -1'
}
@@ -41,7 +41,7 @@ assert.throws(
},
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "groups[0]" argument must be ' +
'one of type number or string. ' +
`Received type ${typeof val}`
diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js
index fe87f24632..e06017920c 100644
--- a/test/parallel/test-stream-finished.js
+++ b/test/parallel/test-stream-finished.js
@@ -129,21 +129,21 @@ const { promisify } = require('util');
assert.throws(
() => finished(rs, 'foo'),
{
- name: /ERR_INVALID_ARG_TYPE/,
+ code: 'ERR_INVALID_ARG_TYPE',
message: /callback/
}
);
assert.throws(
() => finished(rs, 'foo', () => {}),
{
- name: /ERR_INVALID_ARG_TYPE/,
+ code: 'ERR_INVALID_ARG_TYPE',
message: /opts/
}
);
assert.throws(
() => finished(rs, {}, 'foo'),
{
- name: /ERR_INVALID_ARG_TYPE/,
+ code: 'ERR_INVALID_ARG_TYPE',
message: /callback/
}
);
diff --git a/test/parallel/test-ttywrap-invalid-fd.js b/test/parallel/test-ttywrap-invalid-fd.js
index 30c3cd2bc4..ea2e0f276d 100644
--- a/test/parallel/test-ttywrap-invalid-fd.js
+++ b/test/parallel/test-ttywrap-invalid-fd.js
@@ -14,7 +14,7 @@ assert.throws(
() => new tty.WriteStream(-1),
{
code: 'ERR_INVALID_FD',
- name: 'RangeError [ERR_INVALID_FD]',
+ name: 'RangeError',
message: '"fd" must be a positive integer: -1'
}
);
@@ -38,7 +38,7 @@ assert.throws(
});
}, {
code: 'ERR_TTY_INIT_FAILED',
- name: 'SystemError [ERR_TTY_INIT_FAILED]',
+ name: 'SystemError',
message,
info
}
@@ -51,7 +51,7 @@ assert.throws(
});
}, {
code: 'ERR_TTY_INIT_FAILED',
- name: 'SystemError [ERR_TTY_INIT_FAILED]',
+ name: 'SystemError',
message,
info
});
@@ -61,7 +61,7 @@ assert.throws(
() => new tty.ReadStream(-1),
{
code: 'ERR_INVALID_FD',
- name: 'RangeError [ERR_INVALID_FD]',
+ name: 'RangeError',
message: '"fd" must be a positive integer: -1'
}
);
diff --git a/test/parallel/test-url-format-whatwg.js b/test/parallel/test-url-format-whatwg.js
index e5c3e369e8..95332e3f09 100644
--- a/test/parallel/test-url-format-whatwg.js
+++ b/test/parallel/test-url-format-whatwg.js
@@ -26,7 +26,7 @@ assert.strictEqual(
() => url.format(myURL, value),
{
code: 'ERR_INVALID_ARG_TYPE',
- name: 'TypeError [ERR_INVALID_ARG_TYPE]',
+ name: 'TypeError',
message: 'The "options" argument must be of type Object. ' +
`Received type ${typeof value}`
}
diff --git a/test/parallel/test-whatwg-url-custom-parsing.js b/test/parallel/test-whatwg-url-custom-parsing.js
index 34d9062087..e83cc00536 100644
--- a/test/parallel/test-whatwg-url-custom-parsing.js
+++ b/test/parallel/test-whatwg-url-custom-parsing.js
@@ -56,15 +56,13 @@ for (const test of failureTests) {
assert.throws(
() => new URL(test.input, test.base),
(error) => {
- if (!expectedError(error))
- return false;
+ expectedError(error);
// The input could be processed, so we don't do strict matching here
- const match = (`${error}`).match(/Invalid URL: (.*)$/);
- if (!match) {
- return false;
- }
- return error.input === match[1];
+ let match;
+ assert(match = (`${error}`).match(/Invalid URL: (.*)$/));
+ assert.strictEqual(error.input, match[1]);
+ return true;
});
}