Skip to main content

try, catch, and finally

Handle recoverable action errors and perform owned cleanup.

Quick reference​

SyntaxBehavior
try … catch failure … endHandle a recoverable error.
try … finally … endRun cleanup.
try … catch failure … finally … endHandle and clean up.

Example​

<Button title="Save" on-press="try call account.save with {name:'Sam'} catch failure emit failed with {message:failure.message} end" />

Rules and validation​

Try requires catch or finally. Each branch has its own local scope; catch’s error name exists only in catch. Cancellation skips catch and restricts finally to safe synchronous local cleanup. An uncaught interaction error reports to the host while preserving coherent state.

Action errors lesson · Events and cancellation