Subject Catching user defined exceptions
Author Joshua Higgs
Morning all

I have a database that raises exceptions (user defined ones) - ie:

CREATE EXCEPTION
E_EXTRACTPCODEALREADYEXISTS
"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?


[Non-text portions of this message have been removed]