]> git.kaiwu.me - quickjs.git/commitdiff
added Error.isError() (bnoordhuis)
authorFabrice Bellard <fabrice@bellard.org>
Sat, 14 Jun 2025 09:42:54 +0000 (11:42 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 14 Jun 2025 09:42:54 +0000 (11:42 +0200)
TODO
quickjs.c
test262.conf

diff --git a/TODO b/TODO
index acbe84a72d73c8c2f4195ee9df341b4bd2e3f2e2..8d0ff43d0ee65d591223c25b389118394ceb8ac4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -62,5 +62,5 @@ Optimization ideas:
 Test262o:   0/11262 errors, 463 excluded
 Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
 
-Result: 47/79321 errors, 1617 excluded, 6767 skipped
+Result: 46/79346 errors, 1617 excluded, 6754 skipped
 Test262 commit: 4b5d36ab6ef2f59d0a8902cd383762547a3a74c4
index f271927c287e31c4a83f9c40e5b2e9b501b16e81..de2d41b3eb841504a1ad3c5a5d983ebbf75146d8 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -39976,6 +39976,16 @@ 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, JSValueConst this_val,
+                                int argc, JSValueConst *argv)
+{
+    return JS_NewBool(ctx, JS_IsError(ctx, argv[0]));
+}
+
+static const JSCFunctionListEntry js_error_funcs[] = {
+    JS_CFUNC_DEF("isError", 1, js_error_isError),
+};
+
 /* AggregateError */
 
 /* used by C code. */
@@ -52277,6 +52287,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
                                 "Error", 1, JS_CFUNC_constructor_or_func_magic, -1);
     JS_NewGlobalCConstructor2(ctx, obj1,
                               "Error", ctx->class_proto[JS_CLASS_ERROR]);
+    JS_SetPropertyFunctionList(ctx, obj1, js_error_funcs, countof(js_error_funcs));
 
     /* Used to squelch a -Wcast-function-type warning. */
     JSCFunctionType ft = { .generic_magic = js_error_constructor };
index 0966a594a20039047477ca4241cfb89c6ba5857e..3277594541b9444ad865486f528d24a0dba215e7 100644 (file)
@@ -103,7 +103,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