Understanding Python Exceptions: A Comprehensive Guide


Python Exceptions

Built-in Exceptions

The following are the list of built-in exceptions, in their respective hierarchy, in Python.

  • ArithmeticError
    • FloatingPointError
    • OverflowError
    • ZeroDivisionError
  • AssertionError
  • AttributeError
  • BufferError
  • EOFError
  • ExceptionGroup [BaseExceptionGroup]
  • ImportError
    • ModuleNotFoundError
  • LookupError
    • IndexError
    • KeyError
  • MemoryError
  • NameError
    • UnboundLocalError
  • OSError
    • BlockingIOError
    • ChildProcessError
    • ConnectionError
      • BrokenPipeError
      • ConnectionAbortedError
      • ConnectionRefusedError
      • ConnectionResetError
    • FileExistsError
    • FileNotFoundError
    • InterruptedError
    • IsADirectoryError
    • NotADirectoryError
    • PermissionError
    • ProcessLookupError
    • TimeoutError
  • ReferenceError
  • RuntimeError
    • NotImplementedError
    • RecursionError
  • StopAsyncIteration
  • StopIteration
  • SyntaxError
  • SystemError
  • TypeError
  • ValueError
    • UnicodeError
      • UnicodeDecodeError
      • UnicodeEncodeError
      • UnicodeTranslateError
  • Warning
    • BytesWarning
    • DeprecationWarning
    • EncodingWarning
    • FutureWarning
    • ImportWarning
    • PendingDeprecationWarning
    • ResourceWarning
    • RuntimeWarning
    • SyntaxWarning
    • UnicodeWarning
    • UserWarning