O'Reilly logo
  • Chris Kang thinks this is interesting:

class CustomAttributeError(CustomException, AttributeError):
    """An AttributeError which is ALSO a CustomException."""

Now, when your code raises an instance of CustomAttributeError, that exception can be caught by calling code that’s designed to catch all cases of AttributeError as well as by code that’s designed to catch all exceptions raised only by your module.


Cover of Python in a Nutshell, 3rd Edition


This custom exception type can now be caught by either by customer excption or its base exception type.