[Zope3-dev] Please, no bare 'except:' clauses!
R. David Murray
bitz@bitdance.com
Mon, 11 Nov 2002 10:21:53 -0500 (EST)
On Mon, 11 Nov 2002, Barry A. Warsaw wrote:
> But if the three main subsystems you outlined each defined their own
> base exception class (deriving from Exception), and application code
> made sure to catch only the derived classes, I think you could largely
> stil accomplish this goal.
[....]
> except DatabaseError: # All ZODB/transactional errors (conflicts, etc)
>
> except ZopeError: # All Zope framework exceptions
>
> except AppError: # All application defined exceptions
>
> except Exception: # All Python exceptions
But if you trap Exception, you are still trapping DatabaseErrors.
The goal was to have a way to trap everything (including 'python'
errors) *except* for DatabaseErrors. And an enhancedment to
the except command wouldn't be enough, because what we want
to do is specify that DatabaseErrors can't be caught by a framework
that may not be Database-aware.
--RDM