SoFunction
Updated on 2024-11-17

Python Exception Catching and Remediation Examples in Detail

BaseException # Base class for all exceptions
+-- SystemExit # Interpreter request exit
+-- KeyboardInterrupt # User interrupt execution (usually input ^C)
+-- GeneratorExit # Notify exit when generator exception occurs.
+-- Exception # Base class for regular exceptions
+-- StopIteration # The iterator has no more values.
+-- StopAsyncIteration # Must be raised by the __anext__() method of the asynchronous iterator object to stop iteration
+-- ArithmeticError # Base class for built-in exceptions raised by various arithmetic errors
| +-- FloatingPointError # Floating point calculation error
| +-- OverflowError # Numeric operation result too large to represent
| +-- ZeroDivisionError # Divide (or modulo) zero (all data types).
+-- AssertionError # Raised when the assert statement fails.
+-- AttributeError # Failed to reference or assign an attribute.
+-- BufferError # Raised when a buffer-related operation cannot be performed.
+-- EOFError # Raised when the input() function reaches an end-of-file condition (EOF) without reading any data.
+-- ImportError # Failed to import modules/objects
| +-- ModuleNotFoundError # Can't find the module or found None in the
+-- LookupError # Base class for exceptions raised when a key or index used on a map or sequence is invalid
| +-- IndexError # This index is not present in the sequence.
| +-- KeyError # This key is not in the mapping
+-- MemoryError # Memory overflow error (not fatal for Python interpreter)
+-- NameError # Object not declared/initialized (no attributes)
| +-- UnboundLocalError # Access to uninitialized local variables
+-- OSError # OS errors, EnvironmentError, IOError, WindowsError,, and have been merged into OSError, constructor may return subclasses
| +-- BlockingIOError # Operation set blocking object (. socket) to a non-blocking operation
| +-- ChildProcessError # Operation on child process failed
| +-- ConnectionError # Base class for connection-related exceptions
| | +-- BrokenPipeError # Trying to write to a pipe when the other end is closed or trying to write on a socket that has been closed for writes
| | +-- ConnectionAbortedError # Connection attempt aborted by the peer
| | +-- ConnectionRefusedError # Connection attempt rejected by peer
| | +-- ConnectionResetError # Connection reset by peer
| +-- FileExistsError # Create a file or directory that already exists
| +-- FileNotFoundError # Request for non-existent file or directory
| +-- InterruptedError # System call interrupted by an input signal
| +-- IsADirectoryError # Request a file operation on a directory (e.g. ())
| +-- NotADirectoryError # Request directory operations on things that are not directories (e.g. ())
| +-- PermissionError # Attempt to run the operation without sufficient access privileges
| +-- ProcessLookupError # Given process does not exist
| +-- TimeoutError # System function timeout at system level
+-- ReferenceError # () function creates a weak reference that tries to access a garbage-collected object.
+-- RuntimeError # Triggered when an error is detected that doesn't belong to any other category
| +-- NotImplementedError # In user-defined base classes, the abstract method requires the derived class to override the method or the class under development instructs that the actual implementation still needs to be added
| +-- RecursionError # The interpreter detected that the maximum recursion depth was exceeded.
+-- SyntaxError # Python Syntax Error
| +-- IndentationError # Indentation Error
| +-- TabError # Tab and space mixups
+-- SystemError # Interpreter finds internal error
+-- TypeError # Operation or function applied to an object of inappropriate type
+-- ValueError # The operation or function receives an argument with the correct type but an inappropriate value.
| +-- UnicodeError # A Unicode-related encoding or decoding error occurred
| +-- UnicodeDecodeError # Unicode Decode Error
| +-- UnicodeEncodeError # Unicode Encoding Error
| +-- UnicodeTranslateError # Unicode Translation Error
+-- Warning # Base class for warnings
+-- DeprecationWarning # Base class for warnings about deprecated features
+-- PendingDeprecationWarning # Base class for warnings about features that are not recommended for use.
+-- RuntimeWarning # Base class for warnings about suspicious runtime behavior
+-- SyntaxWarning # Base class for warnings about questionable syntax
+-- UserWarning # Base class for user code to generate warnings
+-- FutureWarning # Base class for warnings about deprecated features
+-- ImportWarning # Base class for warnings about possible errors when importing modules.
+-- UnicodeWarning # Base class for Unicode-related warnings
+-- BytesWarning # Base class for warnings related to bytes and bytearray
+-- ResourceWarning # Base class for warnings related to resource usage. Ignored by the default warning filter.