mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
assert: fix deepStrictEqual on errors when cause is not undefined
PR-URL: https://github.com/nodejs/node/pull/55406 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
1 parent
ecc62381a8
commit
4da8d110f3
2 files changed
+50
No files matched your search
@@ -15,6 +15,8 @@ const {
|
||||
StringPrototypeSplit,
|
||||
} = primordials;
|
||||
|
||||
const { isError } = require('internal/util');
|
||||
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
const colors = require('internal/util/colors');
|
||||
const { validateObject } = require('internal/validators');
|
||||
@@ -47,6 +49,15 @@ function copyError(source) {
|
||||
__proto__: null,
|
||||
value: source.message,
|
||||
});
|
||||
if (source.cause !== undefined) {
|
||||
let cause = source.cause;
|
||||
|
||||
if (isError(cause)) {
|
||||
cause = copyError(cause);
|
||||
}
|
||||
|
||||
ObjectDefineProperty(target, 'cause', { __proto__: null, value: cause });
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user