Subject Re: [IBO] SQL Error Trapping
Author Paul Vinkenoog
Hi Jack,

> Am trying to trap errors in the ExecSQL method of tIboSql. The code
> I wrote is as follows. Comment below shows what actually happens
> when an exception is raised.
> SqlError := '';
> with TheQuery do begin
> close;
> with sql do begin
> Clear;
> Add( SQLCommand );
> end;
> try
> ExecSQL;
> (*
> ExecSQL fails with an error message; the exception is not handled
> below. I receive a debugger exception notification stating that my
> project raised exception class EIBO_ISCError with 'ISC ERROR
> *)

That's the debugger halting on - and informing you of - the exception.
This is often not what you want; you can turn this feature on and off
on a per exception class basis, in the Debugger Options.
(Well, you can in BCB; I suppose it's the same in Delphi.)

But after halting and showing you the message, the program is just
paused, not ended. You can resume by clicking Run or Step. And you
_should_ then get to the "except" part of your code, because
EIBO_ISCError is an Exception descendant.

Are you sure the exception handler below is skipped, or do you choose
Program Reset and then restart the app every time?

> except
> on e:exception do
> SqlError := e.Message;
> { end }
> { end except }
> end;
> if SqlError <> '' then
> if pWebApp <> nil then
> SendErrorToWebServer
> else
> ShowMessage( sqlError );
> { end if }
> end; { with TheQuery }

Paul Vinkenoog