AnimatLab  2
Test
ErrorTesting.py
1 import sys, traceback
2 
3 def lumberjack():
4  bright_side_of_death()
5 
6 def bright_side_of_death():
7  return tuple()[0]
8 
9 def testCode() :
10  return tuple()[0]
11 
12 try:
13  testCode()
14 except IndexError:
15  #exc_type, exc_value, exc_traceback = sys.exc_info()
16  #print "*** print_tb:"
17  #traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
18  #print "*** print_exception:"
19  #traceback.print_exception(exc_type, exc_value, exc_traceback,
20  # limit=2, file=sys.stdout)
21  print "*** print_exc:"
22  strErr = traceback.format_exc()
23  print strErr
24  #print "*** format_exc, first and last line:"
25  #formatted_lines = traceback.format_exc().splitlines()
26  #print formatted_lines[0]
27  #print formatted_lines[-1]
28  #print "*** format_exception:"
29  #print repr(traceback.format_exception(exc_type, exc_value,
30  # exc_traceback))
31  #print "*** extract_tb:"
32  #print repr(traceback.extract_tb(exc_traceback))
33  #print "*** format_tb:"
34  #print repr(traceback.format_tb(exc_traceback))
35  #print "*** tb_lineno:", exc_traceback.tb_lineno