Add Error.isError (#682)

It's strictly speaking not at phase 3 yet (almost!) but it's very easy
to implement and quite useful.
This commit is contained in:
Ben Noordhuis 2024-11-13 15:08:06 +01:00 committed by GitHub
parent 2a78706484
commit fa4d2454aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -37928,6 +37928,12 @@ static const JSCFunctionListEntry js_error_proto_funcs[] = {
JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ), JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
}; };
static JSValue js_error_isError(JSContext *ctx, JSValue this_val,
int argc, JSValue *argv)
{
return js_bool(JS_IsError(ctx, argv[0]));
}
static JSValue js_error_get_stackTraceLimit(JSContext *ctx, JSValue this_val) static JSValue js_error_get_stackTraceLimit(JSContext *ctx, JSValue this_val)
{ {
JSValue val; JSValue val;
@ -37971,6 +37977,7 @@ static JSValue js_error_set_prepareStackTrace(JSContext *ctx, JSValue this_val,
} }
static const JSCFunctionListEntry js_error_funcs[] = { static const JSCFunctionListEntry js_error_funcs[] = {
JS_CFUNC_DEF("isError", 1, js_error_isError ),
JS_CGETSET_DEF("stackTraceLimit", js_error_get_stackTraceLimit, js_error_set_stackTraceLimit ), JS_CGETSET_DEF("stackTraceLimit", js_error_get_stackTraceLimit, js_error_set_stackTraceLimit ),
JS_CGETSET_DEF("prepareStackTrace", js_error_get_prepareStackTrace, js_error_set_prepareStackTrace ), JS_CGETSET_DEF("prepareStackTrace", js_error_get_prepareStackTrace, js_error_set_prepareStackTrace ),
}; };

View file

@ -97,7 +97,7 @@ destructuring-assignment
destructuring-binding destructuring-binding
dynamic-import dynamic-import
error-cause error-cause
Error.isError=skip Error.isError
explicit-resource-management=skip explicit-resource-management=skip
exponentiation exponentiation
export-star-as-namespace-from-module export-star-as-namespace-from-module