mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 21:35:34 +00:00

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>
40 lines
716 B
JavaScript
40 lines
716 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
// No args
|
|
assert.throws(
|
|
() => { assert.fail(); },
|
|
{
|
|
code: 'ERR_ASSERTION',
|
|
name: 'AssertionError',
|
|
message: 'Failed',
|
|
operator: 'fail',
|
|
actual: undefined,
|
|
expected: undefined,
|
|
generatedMessage: true
|
|
}
|
|
);
|
|
|
|
// One arg = message
|
|
assert.throws(() => {
|
|
assert.fail('custom message');
|
|
}, {
|
|
code: 'ERR_ASSERTION',
|
|
name: 'AssertionError',
|
|
message: 'custom message',
|
|
operator: 'fail',
|
|
actual: undefined,
|
|
expected: undefined,
|
|
generatedMessage: false
|
|
});
|
|
|
|
// One arg = Error
|
|
assert.throws(() => {
|
|
assert.fail(new TypeError('custom message'));
|
|
}, {
|
|
name: 'TypeError',
|
|
message: 'custom message'
|
|
});
|