Skip to content

Commit fa4d245

Browse files
authored
Add Error.isError (#682)
It's strictly speaking not at phase 3 yet (almost!) but it's very easy to implement and quite useful.
1 parent 2a78706 commit fa4d245

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

quickjs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37928,6 +37928,12 @@ static const JSCFunctionListEntry js_error_proto_funcs[] = {
3792837928
JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
3792937929
};
3793037930

37931+
static JSValue js_error_isError(JSContext *ctx, JSValue this_val,
37932+
int argc, JSValue *argv)
37933+
{
37934+
return js_bool(JS_IsError(ctx, argv[0]));
37935+
}
37936+
3793137937
static JSValue js_error_get_stackTraceLimit(JSContext *ctx, JSValue this_val)
3793237938
{
3793337939
JSValue val;
@@ -37971,6 +37977,7 @@ static JSValue js_error_set_prepareStackTrace(JSContext *ctx, JSValue this_val,
3797137977
}
3797237978

3797337979
static const JSCFunctionListEntry js_error_funcs[] = {
37980+
JS_CFUNC_DEF("isError", 1, js_error_isError ),
3797437981
JS_CGETSET_DEF("stackTraceLimit", js_error_get_stackTraceLimit, js_error_set_stackTraceLimit ),
3797537982
JS_CGETSET_DEF("prepareStackTrace", js_error_get_prepareStackTrace, js_error_set_prepareStackTrace ),
3797637983
};

test262.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ destructuring-assignment
9797
destructuring-binding
9898
dynamic-import
9999
error-cause
100-
Error.isError=skip
100+
Error.isError
101101
explicit-resource-management=skip
102102
exponentiation
103103
export-star-as-namespace-from-module

0 commit comments

Comments
 (0)