>>> import sys
>>> import traceback
>>>
>>> def _get_traceback():
... exc_type, exc_value, exc_traceback = sys.exc_info()
... return traceback.format_exception(exc_type, exc_value, exc_traceback)
...
>>> try:
... raise Exception("this is an exception")
... except:
... print(_get_traceback())
...
...
['Traceback (most recent call last):\n', ' File "<bpython-input-14>", line 2, in <module>\n raise Exception("this is an exception")\n', 'Exception: this is an exception\n']
Created
March 20, 2019 15:52
-
-
Save pariekshit/371d90a52daeac83b0c0ce86d620fbbb to your computer and use it in GitHub Desktop.
Retrieve the last python traceback
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment