[Zope3-dev] Re: NotFound vs NotFoundError

Jim Fulton jim at zope.com
Tue Oct 26 14:44:00 EDT 2004


Jim Fulton wrote:
> 
...

> I'd like to get rid of NotFoundError.  I propose to deprecate it,
> replacing uses of it with (The standard Python exception) LookupError.

After further consideration and discussion, I don't think replacing
NotFoundError with LookupError is the right thing to do.  The reason
is that LookupError is more general.  Code that catches LookupError
might also catch KeyErrors and IndexErrors that reflect bugs in the
code being called.  Code that catches LookupError would then potentially
hide bugs.

It occurs to me that the bug-hiding potential of bare excepts is present
for qualified excepts and is a function of the generality of the exceptions
caught. It follows that the chance of catching and hiding bugs is decreased
as the specificity of the exceptions caught is increased.

I think the right thing to do here is to phase out LookupError over time,
replacing it with more specific exception types.  Unfortunately, this will
take some time. Oh well.

Note that the new more specific errors will need to subclass NotFoundError
so client code that catches notFoundError will still work.  I think we should
probably go ahead and deprecate NotFoundError, at least as soon as most
of the core code has replaced it.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-dev mailing list