Advertisement
Guest User

Custom Exception

a guest
Nov 20th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. class Error(Exception):
  2.     """Base class for exceptions in this module."""
  3.     pass
  4.  
  5. class InputError(Error):
  6.     """Exception raised for errors in the input.
  7.  
  8.    Attributes:
  9.        expression -- input expression in which the error occurred
  10.        message -- explanation of the error
  11.    """
  12.  
  13.     def __init__(self, expression, message):
  14.         self.expression = expression
  15.         self.message = message
  16.  
  17. class TransitionError(Error):
  18.     """Raised when an operation attempts a state transition that's not
  19.    allowed.
  20.  
  21.    Attributes:
  22.        previous -- state at beginning of transition
  23.        next -- attempted new state
  24.        message -- explanation of why the specific transition is not allowed
  25.    """
  26.  
  27.     def __init__(self, previous, next, message):
  28.         self.previous = previous
  29.         self.next = next
  30.         self.message = message
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement