assert: differentiate cases where cause is undefined or missing

PR-URL: https://github.com/nodejs/node/pull/55738
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Antoine du Hamel authored and GitHub committed 2024-11-08 01:01:09 +00:00
1 parent 979526fd99
commit 6af5c4e2b4
3 files changed
+52 -5

No files matched your search

+3 -2
View File
@@ -9,6 +9,7 @@ const {
ObjectAssign,
ObjectDefineProperty,
ObjectGetPrototypeOf,
ObjectPrototypeHasOwnProperty,
String,
StringPrototypeRepeat,
StringPrototypeSlice,
@@ -49,8 +50,8 @@ function copyError(source) {
__proto__: null,
value: source.message,
});
if (source.cause !== undefined) {
let cause = source.cause;
if (ObjectPrototypeHasOwnProperty(source, 'cause')) {
let { cause } = source;
if (isError(cause)) {
cause = copyError(cause);