TRY ... EXCEPT

Syntax

   TRY 
     statements 
   EXCEPT 
     exceptionBlock 
   END

where statements is a sequence of statements (delimited by semicolons) and exceptionBlock is another sequence of statements.

Description

A TRY…EXCEPT statement executes the statements in the initial statements list. If no exceptions are raised, the exception block (exceptionBlock) is ignored and the control passes on to the next part of the IBEBlock.

If an exception is raised during execution of the initial statements list, the control passes to the first statement in the exceptionBlock. Here you can handle any exceptions which may occur using the following functions:

You can also re-raise an exception using the RAISE statement.

Example

   execute ibeblock
   as
   begin
     try
       -- Attempt to insert into non-existent table
       insert into missing_table (f1) values (1);
       ibec_ShowMessage('There were no errors...');
     except
       ErrSQLCode = ibec_err_SQLCode();
       if (ErrSQLCode = -204) then
         ibec_ShowMessage(ibec_err_Message());
       else
         raise;
     end
   end