Subject RE: [IBO] Handling error messages in a single point of the application
Author Roger Vellacott
I handle error messages in the OnError event of IB_Connection. However,
I could find no way to get information about the specific table at this
point.

So I have a generic OnError for all the queries, which handles
query-specific errors with more informative messages, including table
name, and sometimes with a dialog for a user decision. I dynamically
assign the OnError to the queries in code. If starting from scratch, I
would create my own versions of TIB_Cursor, TIB_Query etc, with the
OnError pre-assigned, (and with extra methods such as SafePost,
SafeEdit, FormatDisplayNames, RemoveNullsBeforePost,
SetDecimalPlacesDisplay, PrepareIfUnpreparedAndOpen etc) and use these
throughout.

Roger Vellacott
Passfield Data Systems Ltd


-----Original Message-----
From: Carlos H. Cantu [mailto:listas@...]
Sent: 28 March 2007 01:40
To: IBObjects@yahoogroups.com
Subject: [IBO] Handling error messages in a single point of the
application



Hello!

I plan to use the OnError event from IB_Connection to build a special
parsing routine to handle common database errors, like violation of
primary keys, foreign key violations, etc and build up messages easier
to understand to the common user.

For example, in a primary key violation, I would like to build
something like:

"You tried to save a record in table <table name here> with values in
the fields <list primary key fields here> that already exists. You
can't have two records with the same values in those fields."

This is not easy, specially because the Sender object in that event
will be the Connection component, and not the dataset component that
generated the error.

I will be glad if someone here already have done something like this
and would like to share the code with me.

[]s
Carlos
http://www.firebird <http://www.firebirdnews.org> news.org
FireBase - http://www.FireBase <http://www.FireBase.com.br> .com.br