Skip to content

Commit a3816c8

Browse files
lib: remove unnecessary error formatting
1 parent 0b314ef commit a3816c8

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

lib/internal/util/inspect.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,13 +1902,6 @@ function formatError(err, constructor, tag, ctx, keys) {
19021902
const name = err.name != null ? err.name : 'Error';
19031903
let stack = getStackString(ctx, err);
19041904

1905-
if (tag !== '' && constructor !== null &&
1906-
StringPrototypeIncludes(constructor, 'Error') &&
1907-
!StringPrototypeIncludes(tag, 'Error') &&
1908-
StringPrototypeStartsWith(constructor, tag)) {
1909-
return `[${tag}: ${err.message}]`;
1910-
}
1911-
19121905
removeDuplicateErrorKeys(ctx, keys, err, stack);
19131906

19141907
if ('cause' in err &&

test/parallel/test-util-inspect.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,12 +1432,7 @@ if (typeof Symbol !== 'undefined') {
14321432
);
14331433

14341434
class MiddleErrorPart extends Error {}
1435-
Object.defineProperty(MiddleErrorPart.prototype, Symbol.toStringTag, {
1436-
value: 'Middle',
1437-
configurable: true
1438-
});
1439-
assert.strictEqual(util.inspect(new MiddleErrorPart('foo')),
1440-
'[Middle: foo]');
1435+
assert(util.inspect(new MiddleErrorPart('foo')).includes('MiddleErrorPart: foo'));
14411436

14421437
class MapClass extends Map {}
14431438
assert.strictEqual(util.inspect(new MapClass([['key', 'value']])),

0 commit comments

Comments
 (0)