Error Handling
Try, catch, finally, and throw across the interpreter and compiled backends.
Vyne uses exceptions for recoverable failure. The compiled backend implements them with a bounded longjmp frame stack; the AST interpreter unwinds the evaluation stack.
A try must be followed by catch, finally, or both. The catch variable is optional:
Throwing
throw accepts any value. There is no dedicated exception type; strings are the common case, but numbers, maps, and structs work too.
An uncaught throw terminates the compiled program with a message. The runtime keeps VYNE_MAX_EXC_FRAMES = 64 nested exception frames; exceeding that is a fatal error.
Finally
finally runs on both the normal path and the throwing path, after the matching catch body:
Use finally for state that must be restored regardless of outcome. It also runs when a return leaves the try block.
Interaction with regions
A region unwind is emitted for every open region when an exception crosses a region boundary. Values allocated inside the region are reclaimed before control reaches the handler. If you need a value to survive the exception, commit or move it before throwing.
Error values
catch binds the thrown value without a type annotation. Convert it for display with string(err), or test it if you throw structured values:
Compile-time diagnostics
Exceptions are a runtime mechanism. Compile errors use the VNE-* diagnostic system with source excerpts and suggestions. See Error Codes for the code index and Rulesets for contracts mode.