[Python-ideas] Block-Scoped Exception Handlers

Michael Selik michael.selik at gmail.com
Wed May 4 22:17:25 EDT 2016


On Wed, May 4, 2016, 8:42 PM Nick Coghlan <ncoghlan at gmail.com> wrote:

> @contextmanager
> def chain_errors(exc_to_raise):
>     try:
>         yield
>     except Exception as e:
>         raise exc_to_raise from e
>

Unfortunately, Kyle is using Python 2.7 still, so ``raise from`` won't help
him. The exception context/cause is probably my favorite Python 3 feature.
Or at least in my top 5.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160505/12f31b15/attachment-0001.html>


More information about the Python-ideas mailing list