Skip to content

Commit 8d33e5c

Browse files
BridgeARMylesBorins
authored andcommitted
assert: improve error check
Minor performance improvement. PR-URL: #17574 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9c0c0e6 commit 8d33e5c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎lib/internal/errors.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,14 @@ class AssertionError extends Error{
219219
red='\u001b[31m';
220220
}
221221
constutil=lazyUtil();
222-
if(actual&&actual.stack&&actualinstanceofError)
222+
if(typeofactual==='object'&&actual!==null&&
223+
'stack'inactual&&actualinstanceofError){
223224
actual=`${actual.name}: ${actual.message}`;
224-
if(expected&&expected.stack&&expectedinstanceofError)
225+
}
226+
if(typeofexpected==='object'&&expected!==null&&
227+
'stack'inexpected&&expectedinstanceofError){
225228
expected=`${expected.name}: ${expected.message}`;
229+
}
226230

227231
if(errorDiff===0){
228232
letres=util.inspect(actual);

0 commit comments

Comments
(0)