python errrors code example
Example 1: print type of exception python
try:
someFunction()
except Exception as ex:
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
message = template.format(type(ex).__name__, ex.args)
print (message)
Example 2: exception types python
BaseException
] SystemExit
] KeyboardInterrupt
] GeneratorExit
] Exception
] StopIteration
] StopAsyncIteration
] ArithmeticError
| ] FloatingPointError
| ] OverflowError
| ] ZeroDivisionError
] AssertionError
] AttributeError
] BufferError
] EOFError
] 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
] SyntaxError
| ] IndentationError
| ] TabError
] SystemError
] TypeError
] ValueError
| ] UnicodeError
| ] UnicodeDecodeError
| ] UnicodeEncodeError
| ] UnicodeTranslateError
] Warning
] DeprecationWarning
] PendingDeprecationWarning
] RuntimeWarning
] SyntaxWarning
] UserWarning
] FutureWarning
] ImportWarning
] UnicodeWarning
] BytesWarning
] ResourceWarning