diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2025-06-14 11:42:54 +0200 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2025-06-14 11:42:54 +0200 |
commit | 098f221cf3124a4a423d089bae83b81ccf108d20 (patch) | |
tree | 31f098277a3cad02fa8c4f9f340131ce39f6069a /quickjs.c | |
parent | 9b935dba42c2c108759c50c0c55ef0003b53e725 (diff) | |
download | quickjs-098f221cf3124a4a423d089bae83b81ccf108d20.tar.gz quickjs-098f221cf3124a4a423d089bae83b81ccf108d20.zip |
added Error.isError() (bnoordhuis)
Diffstat (limited to 'quickjs.c')
-rw-r--r-- | quickjs.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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 }; |