how to create my own exception in python

Solutions on MaxInterview for how to create my own exception in python by the best coders in the world

showing results for - "how to create my own exception in python"
Yannik
17 Jun 2016
1class MyException(Exception):
2    pass
3
4raise MyException("My hovercraft is full of eels")
5
6"""With modern Python Exceptions, 
7you don't need to abuse .message, or override .__str__() or .__repr__() 
8or any of it. If all you want is an informative message when your 
9exception is raised, do this