@@ -35282,8 +35282,10 @@ static JSValue iterator_to_array(JSContext *ctx, JSValueConst items)
35282
35282
static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
35283
35283
int argc, JSValueConst *argv, int magic)
35284
35284
{
35285
- JSValue obj, msg, proto;
35285
+ JSValue obj, msg, proto, cause ;
35286
35286
JSValueConst message;
35287
+ int opts;
35288
+ BOOL present;
35287
35289
35288
35290
if (JS_IsUndefined(new_target))
35289
35291
new_target = JS_GetActiveFunction(ctx);
@@ -35311,8 +35313,10 @@ static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
35311
35313
return obj;
35312
35314
if (magic == JS_AGGREGATE_ERROR) {
35313
35315
message = argv[1];
35316
+ opts = 2;
35314
35317
} else {
35315
35318
message = argv[0];
35319
+ opts = 1;
35316
35320
}
35317
35321
35318
35322
if (!JS_IsUndefined(message)) {
@@ -35323,6 +35327,19 @@ static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
35323
35327
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
35324
35328
}
35325
35329
35330
+ if (argc > opts && JS_VALUE_GET_TAG(argv[opts]) == JS_TAG_OBJECT) {
35331
+ present = JS_HasProperty(ctx, argv[opts], JS_ATOM_cause);
35332
+ if (unlikely(present < 0))
35333
+ goto exception;
35334
+ if (present) {
35335
+ cause = JS_GetProperty(ctx, argv[opts], JS_ATOM_cause);
35336
+ if (unlikely(JS_IsException(cause)))
35337
+ goto exception;
35338
+ JS_DefinePropertyValue(ctx, obj, JS_ATOM_cause, cause,
35339
+ JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
35340
+ }
35341
+ }
35342
+
35326
35343
if (magic == JS_AGGREGATE_ERROR) {
35327
35344
JSValue error_list = iterator_to_array(ctx, argv[0]);
35328
35345
if (JS_IsException(error_list))
0 commit comments