Lasso Soft Inc. > Home

[ protect ]

Method

[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.

  • Syntax
protect => {
code
}
Examples
  • Beginner

To protect a block of code from error reporting:

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)

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

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. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft