|Navigation: Clarion.Net (Clarion#) > Clarion# Language Extensions > Exception Handling >====== TRY-CATCH-FINALLY (exception handling block) ======|
statements that can cause an exception
statements to handle exception
statements to cleanup after an exception
|TRY||Arm exception handling|
|statements||any code that may produce an exception.|
|CATCH||Trap an exception|
|statements||Code to perform the appropriate recovery or alert the user. This code is only executed if an exception occurs. You may have multiple CATCH blocks. At the end of each CATCH block you can either throw the same exception (See THROW statement), throw a different exception, or let the code fall out of the CATCH block.|
|FINALLY||Clean up exception handling|
|statements||Code in this block is always executed and can perform cleanup after an exception. The FINALLY block is optional.|
TRY-CATCH-FINALLY is a code block used for exception handling.
If any exception occurs within the TRY block, the .Net runtime searches the CATCH blocks for an appropriate exception. If you have multiple CATCH blocks put the more specific exceptions at the top and the more generic exceptions last. The FINALLY block is always executed and can be used to do cleanup operations after an exception.
The TRY block must be followed by a CATCH or FINALLY. You can have a TRY block without a CATCH as long as you have the FINALLY block.
F() !calling a function
CATCH (Exception e)
MESSAGE('Exception in code: ' & e.Message)
! CODE FOREACH ctrl in SELF.Controls IF(ctrl Is TextBox) IF(NOT ctrl.Tag&=null) colnm&=ctrl.Tag tab&=SELF.m_Row.Table tp&=tab.Columns[colnm].DataType val&=(ctrl TryAS TextBox).Text IF1) END See Also:** THROW