Subject | Re: [IBO] on error code |
---|---|
Author | Geoff Worboys |
Post date | 2001-12-26T00:17:43Z |
> I'm looking for example code dealing with onerror event, code toI've never done it that way - so I have no example code to offer.
> make the errors more friendly like duplicate keys,access violation,
> i'm not sure how do this.
For generic translations to the error messages I attach a handler to
the application OnException event
Application.OnException := DoAppException;
and then I can detect all sorts of exceptions, including my own types
and translate and display as desired.
eg: if E is EIB_ISCError then
begin
with EIB_ISCError(E) do
begin
...
For more specific error message translations I usually put a
try/except block around my post and translate particular error codes
that way. Of course this does not work so well if you are letting
automatic posts occur via committing the transaction or whatever. You
may find you can work around this by using the OnPostError event -
detecting if the exception is EIB_ISCError and then read the errorcode
etc.
The reason for suggesting this, rather than OnError, for translating
messages is that (in my experience) it is easier to come up with
meaningful messages if the processing is associated with a particular
dataset. If you are trying to be completely generic it is difficult
to do any better than the messages offered by IB/FB.
Remember that trigger side effects that lead to interesting results
that may make your own messages misleading, so it is best if the
original message is reported (as additional/technical information) so
that more interesting problems can be isolated when they occur.
Another way to change the IB/FB returned error messages on a generic
basis is to update the messages file - but you will be best to ask on
IB_Support about changes to that file.
hth
--
Geoff Worboys
Telesis Computing