Shared.DC.ZRDB.DA.DA class raises uncatcheable string values exception

Bug #142584 reported by Clemens Robbenhaar
2
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/Shared/DC/ZRDB/DA.py raises a string valued
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?

Revision history for this message
Clemens Robbenhaar (crobbenhaar) wrote :
Revision history for this message
Clemens Robbenhaar (crobbenhaar) wrote :

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,
just close/reject/resolve the issue, as the core
problem (the string exception) has been gone.

Revision history for this message
Tres Seaver (tseaver) wrote :

Status: Pending => Resolved

DA2.patch applied to 2.7 branch and HEAD.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.