From 9039ebd5ad7ca2713bd760de1736ca5fb5248631 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 13 Nov 2024 14:53:33 +0100 Subject: [PATCH] Add Error.isError It's strictly speaking not at phase 3 yet (almost!) but it's very easy to implement and quite useful. --- quickjs.c | 7 +++++++ test262.conf | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index 18382b48..a6936f65 100644 --- a/quickjs.c +++ b/quickjs.c @@ -37928,6 +37928,12 @@ static const JSCFunctionListEntry js_error_proto_funcs[] = { 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) { JSValue val; @@ -37971,6 +37977,7 @@ static JSValue js_error_set_prepareStackTrace(JSContext *ctx, JSValue this_val, } 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("prepareStackTrace", js_error_get_prepareStackTrace, js_error_set_prepareStackTrace ), }; diff --git a/test262.conf b/test262.conf index 9d206b91..e8710fd5 100644 --- a/test262.conf +++ b/test262.conf @@ -97,7 +97,7 @@ destructuring-assignment destructuring-binding dynamic-import error-cause -Error.isError=skip +Error.isError explicit-resource-management=skip exponentiation export-star-as-namespace-from-module