try, catch, and finally
Handle recoverable action errors and perform owned cleanup.
Quick reference
| Syntax | Behavior |
|---|---|
try … catch failure … end | Handle a recoverable error. |
try … finally … end | Run cleanup. |
try … catch failure … finally … end | Handle 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.