Skip to content

Commit 2f6fe7b

Browse files
committed
Implement Error.captureStackTrace
1 parent 0b0b794 commit 2f6fe7b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

quickjs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37999,8 +37999,19 @@ static JSValue js_error_set_prepareStackTrace(JSContext *ctx, JSValue this_val,
3799937999
return JS_UNDEFINED;
3800038000
}
3800138001

38002+
static JSValue js_error_capture_stack_trace(JSContext *ctx, JSValue this_val,
38003+
int argc, JSValue *argv)
38004+
{
38005+
JSValue v = argv[0];
38006+
if (JS_VALUE_GET_TAG(v) != JS_TAG_OBJECT)
38007+
return JS_ThrowTypeErrorNotAnObject(ctx);
38008+
build_backtrace(ctx, v, NULL, 0, 0, JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL);
38009+
return JS_UNDEFINED;
38010+
}
38011+
3800238012
static const JSCFunctionListEntry js_error_funcs[] = {
3800338013
JS_CFUNC_DEF("isError", 1, js_error_isError ),
38014+
JS_CFUNC_DEF("captureStackTrace", 1, js_error_capture_stack_trace),
3800438015
JS_CGETSET_DEF("stackTraceLimit", js_error_get_stackTraceLimit, js_error_set_stackTraceLimit ),
3800538016
JS_CGETSET_DEF("prepareStackTrace", js_error_get_prepareStackTrace, js_error_set_prepareStackTrace ),
3800638017
};

0 commit comments

Comments
 (0)