Author methane
Recipients Nathaniel Manista, ammar2, brett.cannon, docs@python, fdrake, methane, rhettinger
Date 2018-08-31.08:48:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535705329.02.0.56676864532.issue34538@psf.upfronthosting.co.za>
In-reply-to
Content
> https://github.com/search?q=%22except+TemplateError%22&type=Code

For example, I found flask_mako's TemplateException in this search result.

Strictly speaking, this is not base exception class.  It is wraps exception during template rendering.  But "why this class is useful?" is very similar to base exception class.

It provides better traceback for mako template.  They use this class for "particular reason", not because it's generally recommended practice.

And this "particular reason" shouldn't be in Python tutorial, clearly.

---

If we really need exception class hierarchy in tutorial, I think OSError is the best example.  When opening a file, `except OSError:` is much better than `except (PermissionError, FileNotFound, ...)`.  It's the most clear example when common base class for some distinct exceptions is useful.
History
Date User Action Args
2018-08-31 08:48:49methanesetrecipients: + methane, fdrake, brett.cannon, rhettinger, docs@python, Nathaniel Manista, ammar2
2018-08-31 08:48:49methanesetmessageid: <1535705329.02.0.56676864532.issue34538@psf.upfronthosting.co.za>
2018-08-31 08:48:49methanelinkissue34538 messages
2018-08-31 08:48:48methanecreate