How can I get the full stack trace from the Exception object itself?
Consider the following code as reduced example of the problem:
last_exception = None
try:
raise Exception('foo failed')
except Exception as e:
print "Exception Stack Trace %s" % e
The stack trace itself is not stored in the exception object itself. However, you can print the stack trace of the last recent exception using
sys.exc_info()and thetracebackmodule. Example:If you do not want to display the stack trace immediately, it should be possible to store the return value of
sys.exc_info()somewhere.