Subject Re: [IBO] Catching user defined exceptions
Author Jason Wharton
My thought here are that you can either pass the message you want displayed
from the exception itself and leave them all as a standard exception type or
you can pass a code in the exception text and then have the client
application translate that code into the more appropriate class you want.

One way of doing this would be to standardize your exceptions to have a
prefix with an error code of your own making. Then, you can parse out the
error message coming from the exception and look it up in your translation
system and convert it from there.

ErrorCodes are those coming from the API. This would be a nice feature you
could suggest to the developers of Firebird or the Borland engineers.


----- Original Message -----
From: "Joshua Higgs" <Josh@...>
To: <>
Sent: Monday, October 06, 2003 10:25 PM
Subject: [IBO] Catching user defined exceptions

> Morning all
> I have a database that raises exceptions (user defined ones) - ie:
> "Product code already exists on this supplier"
> Trouble is when a query/stored procedure executes, and one of these
exceptions is raised, it is very difficult to trap. This is because IBO
only raises an EIB_ISCError. Checking that the SQLCode is -836 is the easy
part, but turning this exception into a new Exception class - a specific one
relating to the actual exception that was raised isn't so easy. Especially
when you have hundreds of client sites, each with the same Exception names,
but no guarantee that the rdb$Exception_number is the same.
> I am interested in how other developers handle this situation. I have
developed a generic "DBExceptionHandler" that handles this - but it is quite
complicated (happy to discuss and post code if anyone is interested)
> Any thoughts?
> Josh
> ps. Anyone got any ideas on adding another entry on the
IB_ISCError.ErrorCodes list so I can return an integer with the exception?