Try / Catch
Handling expected errors and dealing with the result.
The try/catch
section is designed to handle expected errors and prevent the program terminating, while also allowing special fail-case behaviour to be run.
It forms a tree structure of two possible branches. One or both of these may be run.
Try Block
These must always start with a try
effect as the section header. This header has no inputs or options.
The code in this block will always be attempted. However, it is run with the expectation of failing (an error being thrown.)
The try
section must always be followed by a catch
section.
Catch Block
These must always follow a try
section. The catch %Variable%
section accepts a normal variable.
The error will be stored in this variable.
The code in this block will be run only if the preceding try-section fails. If no error is thrown, the catch
section will not be run.
The catch section will be jumped to after the line that fails
If no error occurs, the catch-section will be skipped.
Any break
instructions will exit this tree entirely (jump to after the catch
section finishes.)
Last updated