Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ JSRuntime *JS_NewRuntime2(const JSMallocFunctions *mf, void *opaque)
#endif
JS_UpdateStackTop(rt);

rt->current_exception = JS_NULL;
rt->current_exception = JS_UNINITIALIZED;

return rt;
fail:
Expand Down Expand Up @@ -6353,10 +6353,15 @@ JSValue JS_GetException(JSContext *ctx)
JSValue val;
JSRuntime *rt = ctx->rt;
val = rt->current_exception;
rt->current_exception = JS_NULL;
rt->current_exception = JS_UNINITIALIZED;
return val;
}

JS_BOOL JS_HasException(JSContext *ctx)
{
return !JS_IsUninitialized(ctx->rt->current_exception);
}

static void dbuf_put_leb128(DynBuf *s, uint32_t v)
{
uint32_t a;
Expand Down Expand Up @@ -13803,7 +13808,7 @@ static int JS_IteratorClose(JSContext *ctx, JSValue enum_obj,

if (is_exception_pending) {
ex_obj = ctx->rt->current_exception;
ctx->rt->current_exception = JS_NULL;
ctx->rt->current_exception = JS_UNINITIALIZED;
res = -1;
} else {
ex_obj = JS_UNDEFINED;
Expand Down Expand Up @@ -17174,7 +17179,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
JS_IteratorClose(ctx, sp[-1], TRUE);
} else {
*sp++ = rt->current_exception;
rt->current_exception = JS_NULL;
rt->current_exception = JS_UNINITIALIZED;
pc = b->byte_code_buf + pos;
goto restart;
}
Expand Down
1 change: 1 addition & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ static inline JS_BOOL JS_IsObject(JSValue v)

JS_EXTERN JSValue JS_Throw(JSContext *ctx, JSValue obj);
JS_EXTERN JSValue JS_GetException(JSContext *ctx);
JS_BOOL JS_HasException(JSContext *ctx);
JS_EXTERN JS_BOOL JS_IsError(JSContext *ctx, JSValue val);
JS_EXTERN void JS_ResetUncatchableError(JSContext *ctx);
JS_EXTERN JSValue JS_NewError(JSContext *ctx);
Expand Down