[docs] [issue34538] Remove encouragement to author a base class for all Exception subclasses in a module
INADA Naoki
report at bugs.python.org
Fri Aug 31 04:48:49 EDT 2018
INADA Naoki <songofacandy at gmail.com> added the comment:
> 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.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34538>
_______________________________________
More information about the docs
mailing list