@@ -6720,7 +6720,7 @@ static bool can_add_backtrace(JSValueConst obj)
6720
6720
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)
6721
6721
return false;
6722
6722
p = JS_VALUE_GET_OBJ(obj);
6723
- if (p->class_id != JS_CLASS_ERROR)
6723
+ if (p->class_id != JS_CLASS_ERROR && p->class_id != JS_CLASS_DOM_EXCEPTION )
6724
6724
return false;
6725
6725
if (find_own_property1(p, JS_ATOM_stack))
6726
6726
return false;
@@ -57684,7 +57684,8 @@ static void js_domexception_mark(JSRuntime *rt, JSValueConst val,
57684
57684
}
57685
57685
57686
57686
static JSValue js_domexception_constructor0(JSContext *ctx, JSValueConst new_target,
57687
- int argc, JSValueConst *argv)
57687
+ int argc, JSValueConst *argv,
57688
+ bool add_backtrace)
57688
57689
{
57689
57690
JSDOMExceptionData *s;
57690
57691
JSValue obj, message, name;
@@ -57711,6 +57712,9 @@ static JSValue js_domexception_constructor0(JSContext *ctx, JSValueConst new_tar
57711
57712
s->message = message;
57712
57713
s->code = -1;
57713
57714
JS_SetOpaqueInternal(obj, s);
57715
+ if (add_backtrace)
57716
+ build_backtrace(ctx, obj, JS_UNDEFINED, NULL, 0, 0,
57717
+ JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL);
57714
57718
return obj;
57715
57719
fail3:
57716
57720
JS_FreeValue(ctx, name);
@@ -57726,7 +57730,7 @@ static JSValue js_domexception_constructor(JSContext *ctx, JSValueConst new_targ
57726
57730
{
57727
57731
if (JS_IsUndefined(new_target))
57728
57732
return JS_ThrowTypeError(ctx, "constructor requires 'new'");
57729
- return js_domexception_constructor0(ctx, new_target, argc, argv);
57733
+ return js_domexception_constructor0(ctx, new_target, argc, argv, true );
57730
57734
}
57731
57735
57732
57736
static JSValue js_domexception_get_name(JSContext *ctx, JSValueConst this_val)
@@ -57803,9 +57807,10 @@ JSValue JS_PRINTF_FORMAT_ATTR(3, 4) JS_ThrowDOMException(JSContext *ctx, const c
57803
57807
}
57804
57808
argv[0] = js_message;
57805
57809
argv[1] = js_name;
57806
- obj = js_domexception_constructor0(ctx, JS_UNDEFINED, 2, argv);
57810
+ obj = js_domexception_constructor0(ctx, JS_UNDEFINED, 2, argv, false );
57807
57811
JS_FreeValue(ctx, js_message);
57808
57812
JS_FreeValue(ctx, js_name);
57813
+ build_backtrace(ctx, obj, JS_UNDEFINED, NULL, 0, 0, 0);
57809
57814
JS_Throw(ctx, obj);
57810
57815
end:
57811
57816
va_end(ap);
0 commit comments