(rontolisp) docs
← Special Forms

throw

(throw tag result)

Transfers control to the innermost active catch whose tag is eq to tag, making result that catch form's value. The stack is really unwound, so every intervening unwind-protect cleanup runs on the way out (innermost first) -- and a handler-case in between does not intercept it, because a throw is a non-local exit, not a signaled condition.

throw is an error when no matching catch is active: the interpreter reports THROW: no enclosing catch for tag ..., the JVM backend raises the equivalent runtime error, and the wasm-GC backends trap (the same way an uncaught error does). The result form is evaluated before the unwind starts.

A throw unwinding through a handler-case is not caught by it:

Because an unmatched throw aborts the program, that path is shown statically:

> (throw 'nope 1)
Error: THROW: no enclosing catch for tag NOPE