User-Defined Exceptions
Categories: Python
Python also allows you to create your own exceptions by deriving classes from the standard built-in exceptions.
Here is an example related to RuntimeError. Here, a class is created that is subclassed from RuntimeError. This is useful when you need to display more specific information when an exception is caught.
Program -
class Networkerror(RuntimeError):
def __init__(self, arg):
self.args = arg