[handle] sets up a section of code, a "handler", such that it will always execute when its surrounding scope exits or a failure occurs. Handlers are useful for ensuring that particular actions are carried out.
[handle] can optionally accept a boolean expression which will be evaluated before the handler is executed. If the expression is true, the handler will be executed. This is logically equivalent to placing the expression in an IF statement surrounding the handler code.
A handler block only comes into effect once the [handle] itself is reached. For example, if a method exits before the [handle] is reached, the handler is not executed. If it exists (or fails) after the [handle] is reached, the handler will be executed.
handle => {
'code to execute always'
}
handle( conditional expression ) => {
'code to execute when condition is true'
}
Use the [Handle] methods. After a [Fail] method is called, Lasso will allow each handle block within the current [Protect] block to run. Each [Handle] block can check the current error message to see whether it should run or not.
The following example performs the code inside the [Handle] block if an unknown error occurs.
Code
Handle(Error_CurrentError == 'Unknown Error') => {
Redirect_URL('error.lasso')
}
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments