sys.excepthook = your_func
for that you must define a function, with following parameters:
def your_func(exc_type, exc_obj, exc_tb):
print "whoaaa my exception"
then you can call an exception
5/0
=>
whoaaa my exception
def your_func(exc_type, exc_obj, exc_tb):
import traceback
l = traceback.format_exception(exc_type, exc_obj, exc_tb)
print type(l)
print l
=>
['Traceback (most recent call last):\n', ' File "./t1.py", line 37, in
traceback.format_exception(...) return us a list of information
as a normal exception traceback
info about sys.xxx
Keine Kommentare:
Kommentar veröffentlichen