Skip to main content

JS_SetUncatchableException

Function JS_SetUncatchableException 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn JS_SetUncatchableException( ctx: *mut JsContext, flag: Bool, )
Expand description

JS_SetUncatchableException: prevent try/catch from seeing the pending exception.

Sets the interpreter’s unwind mode: while it is on, a throw walks past every catch on the stack. It is cleared when the next outermost evaluation starts, so the flag applies to the exception the caller is about to raise and not to the program’s whole future — which is how the reference’s single ctx->is_uncatchable flag behaves too (it is reset on every JS_Throw*).

The same flag is what an interrupt sets, so a host that stops a runaway loop with JS_SetInterruptHandler gets the reference’s behaviour: the script cannot swallow the abort.

§Safety

ctx must be a live context.