@@ -35282,8 +35282,10 @@ static JSValue iterator_to_array(JSContext *ctx, JSValueConst items)
3528235282static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
3528335283 int argc, JSValueConst *argv, int magic)
3528435284{
35285- JSValue obj, msg, proto;
35285+ JSValue obj, msg, proto, cause ;
3528635286 JSValueConst message;
35287+ int opts;
35288+ BOOL present;
3528735289
3528835290 if (JS_IsUndefined(new_target))
3528935291 new_target = JS_GetActiveFunction(ctx);
@@ -35311,8 +35313,10 @@ static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
3531135313 return obj;
3531235314 if (magic == JS_AGGREGATE_ERROR) {
3531335315 message = argv[1];
35316+ opts = 2;
3531435317 } else {
3531535318 message = argv[0];
35319+ opts = 1;
3531635320 }
3531735321
3531835322 if (!JS_IsUndefined(message)) {
@@ -35323,6 +35327,19 @@ static JSValue js_error_constructor(JSContext *ctx, JSValueConst new_target,
3532335327 JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
3532435328 }
3532535329
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+
3532635343 if (magic == JS_AGGREGATE_ERROR) {
3532735344 JSValue error_list = iterator_to_array(ctx, argv[0]);
3532835345 if (JS_IsException(error_list))
0 commit comments