Answers for "python custom errors"

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

Python Answers by Framework

Browse Popular Code Answers by Language