Python Capture Exception
# Basic syntax:
import traceback
try:
your code here
except:
print(traceback.format_exc())
Charles-Alexandre Roy
# Basic syntax:
import traceback
try:
your code here
except:
print(traceback.format_exc())
>>> def catch():
... try:
... asd()
... except Exception as e:
... print e.message, e.args
...
>>> catch()
global name 'asd' is not defined ("global name 'asd' is not defined",)