Last active
March 23, 2021 20:32
-
-
Save sashadev-sky/7ac159a145f923d4a1dcbc4132e87beb to your computer and use it in GitHub Desktop.
Useful exception tree reference for Python3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_exceptions_tree(exception_class, level=0): | |
if level > 1: | |
print(" |" * (level - 1), end="") | |
if level > 0: | |
print(" +---", end="") | |
print(exception_class.__name__) | |
for subclass in exception_class.__subclasses__(): | |
print_exceptions_tree(subclass, level + 1) | |
print_exceptions_tree(BaseException) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/GreedyGoodnaturedPlot$ python3 exceptions_tree.py | |
BaseException | |
+---Exception | |
| +---TypeError | |
| +---StopAsyncIteration | |
| +---StopIteration | |
| +---ImportError | |
| | +---ModuleNotFoundError | |
| | +---ZipImportError | |
| +---OSError | |
| | +---ConnectionError | |
| | | +---BrokenPipeError | |
| | | +---ConnectionAbortedError | |
| | | +---ConnectionRefusedError | |
| | | +---ConnectionResetError | |
| | +---BlockingIOError | |
| | +---ChildProcessError | |
| | +---FileExistsError | |
| | +---FileNotFoundError | |
| | +---IsADirectoryError | |
| | +---NotADirectoryError | |
| | +---InterruptedError | |
| | +---PermissionError | |
| | +---ProcessLookupError | |
| | +---TimeoutError | |
| | +---UnsupportedOperation | |
| | +---ItimerError | |
| +---EOFError | |
| +---RuntimeError | |
| | +---RecursionError | |
| | +---NotImplementedError | |
| | +---_DeadlockError | |
| +---NameError | |
| | +---UnboundLocalError | |
| +---AttributeError | |
| +---SyntaxError | |
| | +---IndentationError | |
| | | +---TabError | |
| +---LookupError | |
| | +---IndexError | |
| | +---KeyError | |
| | +---CodecRegistryError | |
| +---ValueError | |
| | +---UnicodeError | |
| | | +---UnicodeEncodeError | |
| | | +---UnicodeDecodeError | |
| | | +---UnicodeTranslateError | |
| | +---UnsupportedOperation | |
| +---AssertionError | |
| +---ArithmeticError | |
| | +---FloatingPointError | |
| | +---OverflowError | |
| | +---ZeroDivisionError | |
| +---SystemError | |
| | +---CodecRegistryError | |
| +---ReferenceError | |
| +---MemoryError | |
| +---BufferError | |
| +---Warning | |
| | +---UserWarning | |
| | +---DeprecationWarning | |
| | +---PendingDeprecationWarning | |
| | +---SyntaxWarning | |
| | +---RuntimeWarning | |
| | +---FutureWarning | |
| | +---ImportWarning | |
| | +---UnicodeWarning | |
| | +---BytesWarning | |
| | +---ResourceWarning | |
| +---Error | |
| +---_OptionError | |
+---GeneratorExit | |
+---SystemExit | |
+---KeyboardInterrupt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment