QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Create Custom Exception Type

Create a Custom Exception Type that can be called with raise.

  • error-creation
  • organisation

Code

class ExceptionName(BaseException):
    def __init__(message: str):
        super().__init__(message)

Usage

a: int = 1

if a > 0:
  raise ExceptionName('Error Message')