mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
assert: improve error check
Minor performance improvement. PR-URL: https://github.com/nodejs/node/pull/17574 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
4e15679c02
commit
b5825e125c
@ -342,11 +342,14 @@ class AssertionError extends Error {
|
||||
red = '\u001b[31m';
|
||||
}
|
||||
const util = lazyUtil();
|
||||
|
||||
if (actual && actual.stack && actual instanceof Error)
|
||||
if (typeof actual === 'object' && actual !== null &&
|
||||
'stack' in actual && actual instanceof Error) {
|
||||
actual = `${actual.name}: ${actual.message}`;
|
||||
if (expected && expected.stack && expected instanceof Error)
|
||||
}
|
||||
if (typeof expected === 'object' && expected !== null &&
|
||||
'stack' in expected && expected instanceof Error) {
|
||||
expected = `${expected.name}: ${expected.message}`;
|
||||
}
|
||||
|
||||
if (errorDiff === 0) {
|
||||
let res = util.inspect(actual);
|
||||
|
Loading…
Reference in New Issue
Block a user