Shared.DC.ZRDB.DA.DA class raises uncatcheable string values exception
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Fix Released
|
Low
|
Unassigned |
Bug Description
The __call__ method of the class "DA" in the file
lib/python/
exception when trying to connect to a database
which is not open yet.
The string is defined as
"raise 'Database Error', ( ..."
which means it cannot be caught by some except
clause to render a nicer error message
to the (except with a bare "except:" which seems
to be evil.)
As the error may happen not only when testing,
but also e.g. on a production system if the
database to connect to is down temporarily,
it would be nice to be able to catch this exception.
A minimal patch for the CVS head is attached.
The raised exception is still a string, but
it is a string defined on the module level.
Thus can be caught by a "except DatabaseError:"
after a "from Shared.DC.ZRDB.DA import DatabaseError"
Maybe this should be made a class instead?
Uploaded: DA2.patch
I see the string values exception is gone
in Zope 2.7; instead a BadRequest is thrown instead.
As I think this is a little unspecific,
I am resubmitting a new partch, which defines a class
based Exception, just for convenience.
If You don't care about such nitty-gritty details, resolve the issue, as the core
just close/reject/
problem (the string exception) has been gone.