[issue37891] Exceptions tutorial page does not mention raise from
New submission from Niels Albers : raise from has been in the language since python 3, yet the tutorial page teaching about exceptions does not mention it. (see https://docs.python.org/3.7/tutorial/errors.html#raising-exceptions) It would be especially helpful to language newcomers to touch on the possibility of passing error context when raising a new exception in an exception handler. -- assignee: docs@python components: Documentation messages: 349994 nosy: Niels Albers, docs@python priority: normal severity: normal status: open title: Exceptions tutorial page does not mention raise from versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue37891> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37891] Exceptions tutorial page does not mention raise from
Change by Niels Albers : -- type: -> enhancement ___ Python tracker <https://bugs.python.org/issue37891> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37891] Exceptions tutorial page does not mention raise from
Niels Albers added the comment: Thanks Srinivas for the suggestion. IMO exception chaining has more utility than only dealing with new exceptions that are caused by exception handling. It's all about preserving exception context. As both a writer of libraries and a user of such, I do like to have a full context chain when I have to handle an exception (or more importantly as a devops engineeer: log it) Is this edit acceptable? "If you need to track exception context, you can use exception chaining. You can chain exceptions by using the ``from`` clause. Just raise a new exception class or instance from an existing exception. The existing exception will be set as the cause for the new exception." -- ___ Python tracker <https://bugs.python.org/issue37891> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com