python caught exception raised in another module code example
Example 1: only try python
try:
a=2
except:
pass
Example 2: python defualt error handler
import sys
def my_except_hook(exctype, value, traceback):
if exctype == KeyboardInterrupt:
print "Handler code goes here"
else:
sys.__excepthook__(exctype, value, traceback)
sys.excepthook = my_except_hook