Exception feature creep! (was: re-entering in the normal flow after an exception is raised)

Erik Max Francis max at alcyone.com
Fri Oct 1 23:18:02 EDT 2004


Michele Simionato wrote:

> I have no idea about how difficult would be to implement resumable
> exceptions
> in Python; also I am not sure about their cost vs. benefit. For sure,
> in
> 2.5 years of Python programming this is first time I have got an use
> case
> for resumable exceptions; still it is a contrived case. So, I am not
> in
> dire need of resumable exceptions.
> Nevertheless, it is possible that if we had resumable exceptions we
> could use them as a control flow structure in non-exceptional
> situations.
> One could speculate about the idea ...

Resumable exceptions are for when you want to flag cases that may be
exceptional, but that some users of the library may not care about.  A
good example would be a forgiving parser, where resumable exceptions
would be thrown whenever a technical violation, but one that can be
recovered from, occurs.  This is actually a lot more common than you
think; Web browsers and server-side email processing systems are good
examples, where you may want to know about technical violations of
standards and RFCs, but still need to do something meaningful anyway. 
In those cases, someone using the library can not bother catching those
resumable exceptions, in which case they'll act as normal exceptions, or
they can catch them and do something meaningful with them, or they can
simply blanket catch them and immediately resume, something like:

	    ...
	except (FirstResumableException, SecondResumableException), e:
	    e.resume()

Obviously, there are other ways to accomplish this, but they have to use
some mechanism other than exceptions.

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ I will always remember / This moment
    -- Sade



More information about the Python-list mailing list