Answers for "how to make an exception in python"

14

throwing an exception python

raise Exception("message")
Posted by: Guest on June-22-2020
0

how to create my own exception in python

class MyException(Exception):
    pass

raise MyException("My hovercraft is full of eels")

"""With modern Python Exceptions, 
you don't need to abuse .message, or override .__str__() or .__repr__() 
or any of it. If all you want is an informative message when your 
exception is raised, do this
Posted by: Guest on August-31-2021

Code answers related to "how to make an exception in python"

Python Answers by Framework

Browse Popular Code Answers by Language