On 14 September 2012 03:32, Nick Coghlan <ncoghlan@gmail.com> wrote:
On Fri, Sep 14, 2012 at 11:52 AM, Stephen J. Turnbull
<stephen@xemacs.org> wrote:
> ISTR there were discussions of "qualified except" clauses here maybe
> 6mo to 1yr ago?  That is, they'd look something like
>
> try:
>      operation()
> except IOError as err if err.errno == 2:
>      do_something()
> except Exception:
>      logger.error("Error performing operation: {}".format(err.message)")
>      some_clean_up()
>      raise
>
> Again ISTR that this got spiked for some reason, but maybe it will be
> of use to the OP in formulating his next idea.  Sorry for the lack of
> precise reference.

They were one of the ideas discussed when Antoine was writing PEP
3151. As I recall, nobody could think of any good use cases that
didn't involve errno checking, and PEP 3151 provides a far more
elegant (and cross-platform) solution to most problems that require
errno checking in versions prior to 3.3.


Ah I didn't know about that, maybe I chose a bad example with IOError.

The reason that got me thinking is I had to handle specific S3ResponseErrors from boto.

the S3ResponseError exception class has a code attribute (or errorcode, i forget exactly).

Surely in this case and a lot of other modules different exceptions are grouped together that are likely to want to be handle differently?

URLError and HTTPError I'm sure fall into this catagory
 
Cheers,
Nick.

--
Nick Coghlan   |   ncoghlan@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas