Answers for "how to create custom errors in python"

2

python custom errors

class MyException(Exception):
  """You can put code here"""
  pass

class MyOtherException(MyException):
  """You can also put code here"""
  pass
Posted by: Guest on June-29-2021
1

python custom errors

>>> class CustomError(Exception):
...     pass
...

>>> raise CustomError
Traceback (most recent call last):
...
__main__.CustomError

>>> raise CustomError("An error occurred")
Traceback (most recent call last):
...
__main__.CustomError: An error occurred
Posted by: Guest on June-29-2021

Code answers related to "how to create custom errors in python"

Python Answers by Framework

Browse Popular Code Answers by Language