Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread EDB and exception handling
Sat, Aug 9 2008 1:19 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Hello,

I'm trying to implement automatic recovery from some exceptions and/or
show customized error messages and instructions to the user about what
to do when automatic recovery is not possible, however I can't figure
out an easy way to get all the information I need - table name, name of
the violated constraint, etc when an exception is raised. We can get the
error code and error message from EEDBError, but nothing else...

Until now, the only way I could think of is to parse the error messages
looking for the information I need (table name, column name, name of the
violated constraint, etc), but this is not an easy task... Also, error
messages can change in future versions.

Any ideas, other then parse the error messages, to find the table name,
the name of the violated constraint, etc. from inside an exception block
(I'm talking about Delphi code, not PSM/SQL) when an exception is raised?

--
Fernando Dias
[Team Elevate]


Sat, Aug 9 2008 1:42 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Fernando


Which events are you raising the exception in?

Roy Lambert [Team Elevate]
Sat, Aug 9 2008 2:07 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Fernando


Should also have asked what type of operations are you trying to recover from and although you say <<Delphi code, not PSM/SQL>> are you executing sql?

Roy Lambert [Team Elevate]
Sat, Aug 9 2008 2:12 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Roy,

It's not *the exception* but EDB exceptions in general, in many possible
places: TApplicationEvents.OnException, TEDBTable.BeforePost,
TEDBTable.BeforeDelete and in many try/except blocks all over the
application.

--
Fernando Dias
[Team Elevate]
Sat, Aug 9 2008 2:50 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Roy,

> Should also have asked what type of operations are you trying to recover from
For example:
In some tables, I want to automatically generate a different value for a
unique column and retry the insert every time an exception is raised
because of a duplicate value, but the only information I can get from
EEDBError is ErrorCode #1004 indicating that a constraint was violated -
I don't know what constraint was violated.
In many cases I just want to generate personalized error messages to the
user, instead of the default EDB messages.

> and although you say <<Delphi code, not PSM/SQL>> are you executing sql?
Yes, but that's not the point - what I mean is I'm handling this kind of
exceptions using Delphi code, not from inside stored procedure or scripts.

--
Fernando Dias
[Team Elevate]
Sat, Aug 9 2008 3:06 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Fernando


Looking at the manual you can get four bits of information ErrorCode, ErrorColumn, ErrorLine & ErrorMsg but I'm not sure any of them, or any combination will readily give you what you're looking for. I think you need to ask Tim for additional properties.

Roy Lambert [Team Elevate]
Sun, Aug 10 2008 8:19 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Roy,

Yes, that's my opinion too, but I was hoping someone could come up with
a different solution. Thanks.

--
Fernando Dias
[Team Elevate]
Image