Subject Re: [IBO] Catching IB exceptions
Author Geoff Worboys
> I need your advise on the following problem:
> I got a one form with some TIB_Query and controls for editing data
> (TIB_Grid, TIB_Edit ....).
> What is the best way and place in the code to catch exceptions like
> violation of PRIMARY, UNIQUE KEY, FOREIGN KEY etc. and next
> to translate it for user ?

Like many things, the "best way" is likely to be dependant on the
details of your application. Someways of handling the situation
include...

Use the OnError handler available with many of the the TIB_*
components. There are some comments in the online help as what you
can acheive with this. If most of your code is using standard IBO
features such as UpdateBar etc, this may be your best bet.

If you have implemented your own buttons etc - which means you are
doing some of the control in code, then you may find it more suitable
to simply catch errors when they happen...

try
<something>
except
on E: EIB_ISCError do
begin
if ((E.ERRCODE = isc_unique_key_violation) or
(E.ERRCODE = isc_no_dup)) then
<do something>
end;
end;


HTH

Geoff Worboys
Telesis Computing