Subject | Re: [IBO] Handling a FK violation in OnError |
---|---|
Author | Geoff Worboys |
Post date | 2006-09-22T05:24:43Z |
Antti,
exceptions and display them using my own dialog box. In that
processing I detect EIB_ISCError (in your case that will
probably be EIBO_ISCError because you are using TIBODataset).
When I find the specific error types I do various interesting
things such as friendly message translation - in some cases
pulling additional info back from the database itself (this
can be problematic).
Application.OnException has the advantage of being called from
around the message/event loop. This generally (callbacks and
sendmessage can be an issue) means that the particular section
of application code has completed what it wanted to do,
including any clean up etc. Note that reliance on particular
objects still existing can be an issue - as application cleanup
may have removed them. In such cases you can use the component
OnError handler to extract the information you need (and may
still be available at that point) and then throw your own
exception - to once again be caught by Application.OnException
and displayed appropriately.
(I hope that all made sense.)
The main places I use IBO's own internal OnError events is when
I specifically want to change default processing - for example
in TIB_Script where I may want to ignore or log errors or
whatever. Actually blocking errors can be a problem, as you
have discovered.
--
Geoff Worboys
Telesis Computing
> thank you. I will check the code you pointed to (dang, I suckPractice makes perfect. :-)
> at reading other people's code ;-),
> and yes, I do use the update bar and I use it a lot. I'mI actually use Application.OnException to collect all the
> wondering if I'm doing something out of the ordinary here /
> should I be doing this in a different way? I pretty much only
> need to change the error message to something more end-user
> friendly in some cases, such as the FK violation on delete...
exceptions and display them using my own dialog box. In that
processing I detect EIB_ISCError (in your case that will
probably be EIBO_ISCError because you are using TIBODataset).
When I find the specific error types I do various interesting
things such as friendly message translation - in some cases
pulling additional info back from the database itself (this
can be problematic).
Application.OnException has the advantage of being called from
around the message/event loop. This generally (callbacks and
sendmessage can be an issue) means that the particular section
of application code has completed what it wanted to do,
including any clean up etc. Note that reliance on particular
objects still existing can be an issue - as application cleanup
may have removed them. In such cases you can use the component
OnError handler to extract the information you need (and may
still be available at that point) and then throw your own
exception - to once again be caught by Application.OnException
and displayed appropriately.
(I hope that all made sense.)
The main places I use IBO's own internal OnError events is when
I specifically want to change default processing - for example
in TIB_Script where I may want to ignore or log errors or
whatever. Actually blocking errors can be a problem, as you
have discovered.
--
Geoff Worboys
Telesis Computing