From db9dbd0a2b6d115c9ef3c0dc37e0c669ef4844e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Isager=20Dalsgar=C3=B0?= Date: Wed, 8 May 2024 23:19:15 +0200 Subject: [PATCH] Add `JS_HasException()` (#265) --- quickjs.c | 5 +++++ quickjs.h | 1 + 2 files changed, 6 insertions(+) diff --git a/quickjs.c b/quickjs.c index 61cfb3d..bbba005 100644 --- a/quickjs.c +++ b/quickjs.c @@ -6402,6 +6402,11 @@ JSValue JS_GetException(JSContext *ctx) return val; } +JS_BOOL JS_HasException(JSContext *ctx) +{ + return !JS_IsNull(ctx->rt->current_exception); +} + static void dbuf_put_leb128(DynBuf *s, uint32_t v) { uint32_t a; diff --git a/quickjs.h b/quickjs.h index f0bab38..8e93887 100644 --- a/quickjs.h +++ b/quickjs.h @@ -633,6 +633,7 @@ static inline JS_BOOL JS_IsObject(JSValueConst v) JSValue JS_Throw(JSContext *ctx, JSValue obj); JSValue JS_GetException(JSContext *ctx); +JS_BOOL JS_HasException(JSContext *ctx); JS_BOOL JS_IsError(JSContext *ctx, JSValueConst val); void JS_ResetUncatchableError(JSContext *ctx); JSValue JS_NewError(JSContext *ctx);