[Zope-dev] Pointless exception re-raising in DA.py

Dieter Maurer dieter at handshake.de
Wed Mar 24 15:57:28 EST 2004


Chris Withers wrote at 2004-3-24 15:36 +0000:
> ...
>>  The reason is that I would like to treat errors when accessing
>> an external data base different from other errors; often the data
>> obtained there is only "optional" to the page, so I don't want to show
>> usered the error page in this case, only to fill up doem slot with
>> "sorry, that certain piece of information is not availabe, because our
>> sql data base sucks".
>
>...this is an application level decision. The code currently makes it very easy, 
>but at the expense of debugging any unexpected exceptions that code throws. 

You can have both!
It is just a little more work for you (I know you are lazy...):

   try: DB__=dbc()
   except:
     exc_type, exc_value, trc = sys.exc_info()
     raise DatabaseError('%s is not connected to a database' % self.id,
                         exc_type,
			 exc_value), trc
     trc = None


Define "DatabaseError" in such a way that its "__str__" includes
information about the original exception.

-- 
Dieter



More information about the Zope-Dev mailing list