Skip to content

Commit 56da486

Browse files
committed
1 parent 8557bd0 commit 56da486

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

quickjs.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
17001700
#endif
17011701
JS_UpdateStackTop(rt);
17021702

1703-
rt->current_exception = JS_NULL;
1703+
rt->current_exception = JS_UNINITIALIZED;
17041704

17051705
return rt;
17061706
fail:
@@ -6353,10 +6353,15 @@ JSValue JS_GetException(JSContext *ctx)
63536353
JSValue val;
63546354
JSRuntime *rt = ctx->rt;
63556355
val = rt->current_exception;
6356-
rt->current_exception = JS_NULL;
6356+
rt->current_exception = JS_UNINITIALIZED;
63576357
return val;
63586358
}
63596359

6360+
JS_BOOL JS_HasException(JSContext *ctx)
6361+
{
6362+
return !JS_IsUninitialized(ctx->rt->current_exception);
6363+
}
6364+
63606365
static void dbuf_put_leb128(DynBuf *s, uint32_t v)
63616366
{
63626367
uint32_t a;
@@ -13803,7 +13808,7 @@ static int JS_IteratorClose(JSContext *ctx, JSValue enum_obj,
1380313808

1380413809
if (is_exception_pending) {
1380513810
ex_obj = ctx->rt->current_exception;
13806-
ctx->rt->current_exception = JS_NULL;
13811+
ctx->rt->current_exception = JS_UNINITIALIZED;
1380713812
res = -1;
1380813813
} else {
1380913814
ex_obj = JS_UNDEFINED;
@@ -17174,7 +17179,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
1717417179
JS_IteratorClose(ctx, sp[-1], TRUE);
1717517180
} else {
1717617181
*sp++ = rt->current_exception;
17177-
rt->current_exception = JS_NULL;
17182+
rt->current_exception = JS_UNINITIALIZED;
1717817183
pc = b->byte_code_buf + pos;
1717917184
goto restart;
1718017185
}

quickjs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ static inline JS_BOOL JS_IsObject(JSValue v)
585585

586586
JS_EXTERN JSValue JS_Throw(JSContext *ctx, JSValue obj);
587587
JS_EXTERN JSValue JS_GetException(JSContext *ctx);
588+
JS_BOOL JS_HasException(JSContext *ctx);
588589
JS_EXTERN JS_BOOL JS_IsError(JSContext *ctx, JSValue val);
589590
JS_EXTERN void JS_ResetUncatchableError(JSContext *ctx);
590591
JS_EXTERN JSValue JS_NewError(JSContext *ctx);

0 commit comments

Comments
 (0)