Skip to content

Commit

Permalink
Reduce cascading errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Oct 28, 2017
1 parent 304c280 commit 8bb8e95
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions trepan/post_mortem.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,27 @@ def pm(frameno=1, dbg=None):

def post_mortem_excepthook(exc_type, exc_value, exc_tb, tb_fn=None):
if str(exc_type) == str(DebuggerQuit): return
if str(exc_type) == str(DebuggerRestart):
if ( exc_value and exc_value.sys_argv and
len(exc_value.sys_argv) > 0 ):
print("No restart handler - trying restart via execv(%s)" %
repr(exc_value.sys_argv))
os.execvp(exc_value.sys_argv[0], exc_value.sys_argv)
else:
print("No restart handler, no params registered")
print("Entering post-mortem debugger...")
else:
if tb_fn:
tb_fn(exc_type, exc_value, exc_tb)
try:
if str(exc_type) == str(DebuggerRestart):
if ( exc_value and exc_value.sys_argv and
len(exc_value.sys_argv) > 0 ):
print("No restart handler - trying restart via execv(%s)" %
repr(exc_value.sys_argv))
os.execvp(exc_value.sys_argv[0], exc_value.sys_argv)
else:
print("No restart handler, no params registered")
print("Entering post-mortem debugger...")
else:
traceback.print_exception(exc_type, exc_value, exc_tb)
print("Uncaught exception. Entering post-mortem debugger...")
if tb_fn:
tb_fn(exc_type, exc_value, exc_tb)
else:
traceback.print_exception(exc_type, exc_value, exc_tb)
print("Uncaught exception. Entering post-mortem debugger...")
pass
post_mortem((exc_type, exc_value, exc_tb))
print("Post-mortem debugger finished.")
except:
pass
post_mortem((exc_type, exc_value, exc_tb))
print("Post-mortem debugger finished.")
return


Expand Down

0 comments on commit 8bb8e95

Please sign in to comment.