[Zope-CMF] Re: [dev] some questions regarding Exceptions

Dieter Maurer dieter at handshake.de
Thu Sep 18 13:12:46 EDT 2003


Yuppie wrote at 2003-9-18 12:56 +0200:
 > Dieter Maurer wrote:
 > 
 > > Yuppie wrote at 2003-9-16 12:59 +0200:
 > >  > ...
 > >  > After rereading the python docs, I think the root exception has to be
 > >  > 
 > >  >    class CMFError(Exception):
 > >  > 
 > >  > Thats the easy part.
 > > 
 > > I do not think, it should derive from "Exception" but from
 > > "StandardError".
 > > 
 > > There are exceptions that are not errors, e.g. ConflictError.
 > > It should be easy to catch just errors with "except StandardError"
 > > and let non-error exceptions through.
 > 
 > Look at POSException.py:
 > 
 >    class POSError(StandardError): ...
 >    class TransactionError(POSError): ...
 >    class ConflictError(TransactionError): ...
 > 
 > ConflictError is derived from StandardError! "except StandardError" 
 > isn't saver than a bare except.

There has been a discussion that this should be changed.
Just to be make it easy to catch errors without catching
exceptions which are not errors.

 > > This is widely not adhered, too, but we may start with it.
 > 
 > Are you sure thats the Right Way?

I find it convincing...

Have a small set of exception base classes that distinquish
the various kinds of exceptions: Errors, Problems (such
as "ConflictError"), Warnings, ...

 > <http://www.python.org/doc/current/tut/node10.html#SECTION0010500000000000000000>
 > shows an example with
 > 
 >    class Error(Exception): ...

That is one reason why the use of "StandardError" as base class for errors
is not widely adhered, too.

 > <http://www.python.org/doc/current/lib/module-exceptions.html> says:
 > 
 > StandardError:=The base class for all built-in exceptions except 
 > StopIteration and SystemExit.

I read this, before I posted :-)

The note on "StopIteration" in the Python (2.3) documentation

  "... this is derived from Exception rather than StandardError,
  since this is not considered an error in its normal application."

also tells me that Zope/CMF should derive exception classes from
"StandardError" when they are considered errors
and from "Exception" when they are not (such as "ConflictError").


Dieter



More information about the Zope-CMF mailing list