[Zope-dev] Catching (external database connectivity) specific exceptions; was: Pointless exception re-raising in DA.py

Chris Withers lists at simplistix.co.uk
Fri Mar 26 06:22:35 EST 2004


Clemens Robbenhaar wrote:

>  Hm, figuring out the "right" exception actually the problem; if the
> data base connector would raise an exception of a certain type due to
> unability to connect I could catch these and let the others pass.

Which DA are you using? It _should_ do that...

>  Unfortunately I am not able to figure out the interesting ones so
> quickly by experimenting, because I cannot think about (or even
> reproduce) everything that may actually fail.

The specifc DA you are using should subclass all it's exceptions from a base 
exception. ZOracleDA does this the right wya, fro mwhat I've seen...

>  Unfortunately there is no sich general exception for it. 

Well, it's up to the DA author to provide one...

>(such as java
> has as java.sql.SQLException ... often not very informative, but at least one
> knows its from the data base.)
>  Maybe the "DatabaseError" class could remain in the DA.py, so specific
> data base connections could reuse this exception type?

Sounds like a plan, now you jus thave to persuade the DA authors to start using 
it ;-)

> product to use this exception now? (btw: does somebody know, if Zope3
> would maybe have such an "external data source connection" specific exception?)

Ask on zope3-dev at zope.org...

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk




More information about the Zope-Dev mailing list