[Protect => { code }] protects a block of code.
If code inside the container throws an error, or a [Fail] method is executed inside the container, then the error is not allowed to propagate outside the protected block.
If the protected code block includes any [Handle => { code }] blocks, they will be called when an error is reported within the protected block or when the protected block completes.
protect => {
code
}
Use the [Protect=> {code}] method. Lasso will not allow any error messages to propagate outside of a protect block. The following code fails with an error -1, and an error message "Unknown Error", but this error is not reported to the visitor since it is caught by the protect block.
Code
protect => {
fail(-1, 'Unknown Error')
}
Result
(no error displayed)
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
Note that an error handle code block has to be the first section of the protect block in order to work.
Posted on: 14 April 2011