3tj9
last updated 2 years ago by osuchw #
The section describing User-defined Exceptions should begin with the simplest possible example and only later on show more elaborate ones. I recall when learning Python it took me a while to realize that I did not need to override any methods to utilize custom exceptions. For example:
>>> class MyError(Exception):
... pass
...
>>> raise MyError, 'Something bad happened'
Traceback (most recent call last):
File "<input>", line 1, in ?
MyError: Something bad happened
