[Python-ideas] Arguments to exceptions

Koos Zevenhoven k7hoven at gmail.com
Fri Jul 7 08:23:35 EDT 2017

On Fri, Jul 7, 2017 at 7:28 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> As a result, our advice is to *avoid* trying to come up with systemic
> fixes for structured exception handling, and instead focus on specific
> use cases of "I want *this* exception type to have *that* attribute
> for *these* reasons". Those kinds of proposals usually don't even rise
> to the level of needing a PEP - they're just normal RFEs on the issue
> tracker.
It would seem to make sense to try and 'standardize' how this is done for
the cases where it is done at all. For example, there could be some kind of
collection in the exceptions (not necessarily all exceptions) that contains
all the objects that participated in the operation that led to the
exception. Something consistent across the different exception types would
be easier to learn.

For instance, with an AttributeError coming from a deeper call stack, you
might want to check something like:

    myobj in exc.participants


    myname in exc.participants

This could also be more precise. For instance 'participants' might be
divided into 'subjects' and 'objects', or whatever might be a suitable
categorization for a broad range of different exceptions. This would need
some research, though, to find the most useful naming and guidelines for
these things.

This might also be handy when converting from one exception type to
another, because the 'participants' (or whatever they would be called)
might stay the same.

-- Koos

+ Koos Zevenhoven + http://twitter.com/k7hoven +
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170707/003a286e/attachment.html>

More information about the Python-ideas mailing list