[Zope-CMF] Re: [dev] some questions regarding Exceptions
Tres Seaver
tseaver at zope.com
Tue Sep 16 11:42:02 EDT 2003
On Tue, 2003-09-16 at 06:59, Yuppie wrote:
> Hi!
>
>
> Seb Bacon wrote:
> > Yuppie wrote:
> >> Something like this?
> >>
> >> class CMFError(StandardError):
> >> ...
> >> class MembershipError(CMFError):
> >> ...
> >> class MetadataError(CMFError):
> >> ...
> >> ...
> >
> >
> > Definitely. I can imagine it might be worth discussing the exception
> > hierarchy a bit.
>
> After rereading the python docs, I think the root exception has to be
>
> class CMFError(Exception):
>
> Thats the easy part.
>
>
> For the hierarchy I see two possible approaches:
>
> a) by type (CMFValueError, CMFUnauthorizedError, ...)
>
> b) by module/context (MembershipError, MetadataError, ...)
>
> We also could combine these two:
>
> class MembershipValueError(ValueError, CMFError):
> class MembershipUnauthorizedError(Unauthorized, CMFError):
> class MetadataValueError(ValueError, CMFError):
> class MetadataUnauthorizedError(Unauthorized, CMFError):
> ...
>
>
> I attached the result of grepping CMF 1.4. Currently both approaches
> exist. The combined solution would provide the best backwards
> compatibility, but I'm afraid that's overkill.
>
> I'd prefer approach b).
-1. The existing exception types have well-understood semantics; the
new "module-centric" ones would not. In particular, third-party code
which currently does::
except ValueErrror, err:
must continue to work, which implies one of:
- status quo ante
- approach a)
- approach "c)" ;)
Tres.
--
===============================================================
Tres Seaver tseaver at zope.com
Zope Corporation "Zope Dealers" http://www.zope.com
More information about the Zope-CMF
mailing list