Overview Module Function Class Tea 3.2.5 Reference Documentation
© 2009 PDM&FC

Function catch

catch aBlock [aSymbol [aStSymbol]]

Executes a code block and checks if any errors were thrown.

Parameters:
aBlock - The code block object that will be executed.
aSymbol - Symbol that identifies the variable that will receive either the result of executing the block or the error message.
aStSymbol - Symbol that identifies the variable that will receive the stack trace as a string, or null if no error. (Since version 3.2.2).
Returns:
True if the execution of the code block generated a runtime error. False otherwise.

Executes the code block object received as argument aBlock. If the execution of a aBlock generates a runtime error the error is catched and the catch function returns true. In this case, if the aSymbol argument is specified, the variable identified by that symbol will be assigned a reference to a string object representing the message associated with the runtime error that was generated. Also in this case, if the aStSymbol argument is specified, the variable identified by that symbol will be assigned a reference to a multi-line string object with the error message and a human readable stack trace representation.

If the execution of aBlock concludes with no error then the variable identified by aSymbol will receive the result of the execution of aBlock. In this case the catch will return the false boolean value. The result of the execution of a block is the value returned by the last statement executed inside the block.

If there is no variable identified by aSymbol or aStSymbol accessible in the current context then one will be created in the current context.


Overview Module Function Class Tea 3.2.5 Reference Documentation
© 2009 PDM&FC
Report a bug or request new features
© 2009