catch an exception in one place, and raise it again in another.
when the original exception was caught:
exc_info = sys.exc_info()
In a difference place, we get the reference to the exc_info stored above:
In Python 2:
raise exc_info, exc_info, exc_info
In Python 3:
raise exc_info.with_traceback(exc_info, exc_info)
When should we use “raise e?” here ‘e’ is an exception that you’ve just caught, Never. Doing so will always lose the traceback information from the previous frames on the stack, and obfuscate the point of origin of the original error.
See the difference between “raise e” and “raise”:
http://www.markbetz.net/2014/04/30/re-raising-exceptions-in-python/ http://nedbatchelder.com/blog/200711/rethrowing_exceptions_in_python.html http://stackoverflow.com/questions/14503751/how-to-write-exception-reraising-code-thats-compatible-with-both-python-2-and-p