Links
- errno
- Warnings
- Exception hierarchy
- Exceptions
- User-defined Exceptions
- OS exceptions
- BaseException
- PEP 3151 - Reworking the OS and IO exception hierarchy
- “Inner exception” (with traceback) in Python?
- Raise statement has 3 params
- raise statement
- sys.exc_info()
- Statements
Notes
- Changed in version 3.3:
EnvironmentError, IOError, WindowsError, VMSError, socket.error, select.error and mmap.error
have been merged intoOSError
.
Snippets
Inner Exceptions
python 2.X
import sys try: ... except SomeException as e: traceback = sys.exc_info()[2] new_exception = NewException("{exception}. While performing operation {OP}.".format( exception=e, OP="operation")) raise new_exception, None, traceback
python 3.x: with_traceback
See BaseException
try: ... except SomeException: traceback = sys.exc_info()[2] raise OtherException(...).with_traceback(traceback)