Home made exception
You can create your own exception classes that will allow the user to know what kind of an exception was caught or to capture only the exceptions of that type.
examples/exceptions/home_made_exception.py
class MyException(Exception): pass def some(): raise MyException("Some Error") def main(): try: some() except Exception as err: print(err) print("Type: " + type(err).__name__) try: some() except MyException as err: print(err) main()
Some Error Type: MyException Some Error