def report_exception(self): """Display an alert box describing the most recent exception, and giving the options Continue, Traceback or Abort. Traceback displays a traceback and continues; Abort raises SystemExit.""" try: exc_type, exc_val, exc_tb = sys.exc_info() exc_desc = "%s: %s" % (exc_type.__name__, exc_val) self.print_traceback(exc_desc, exc_tb) from GUI.Alerts import alert3 message = "Sorry, something went wrong." result = alert3('stop', "%s\n\n%s" % (message, exc_desc), "Continue", "Abort", "Traceback", default=1, cancel=None, width=450, lines=5) if result == 1: # Continue return elif result == -1: # Traceback self.display_traceback(exc_desc, exc_tb) return else: # Abort raise SystemExit except (KeyboardInterrupt, SystemExit): os._exit(1) except: print("---------- Exception while reporting exception ----------", file=sys.stderr) traceback.print_exc() print("------------------ Original exception -------------------", file=sys.stderr) traceback.print_exception(exc_type, exc_val, exc_tb)
def report_exception(self): """Display an alert box describing the most recent exception, and giving the options Continue, Traceback or Abort. Traceback displays a traceback and continues; Abort raises SystemExit.""" try: exc_type, exc_val, exc_tb = sys.exc_info() exc_desc = "%s: %s" % (exc_type.__name__, exc_val) self.print_traceback(exc_desc, exc_tb) from GUI.Alerts import alert3 message = "Sorry, something went wrong." result = alert3( "stop", "%s\n\n%s" % (message, exc_desc), "Continue", "Abort", "Traceback", default=1, cancel=None, width=450, lines=5, ) if result == 1: # Continue return elif result == -1: # Traceback self.display_traceback(exc_desc, exc_tb) return else: # Abort raise SystemExit except (KeyboardInterrupt, SystemExit): os._exit(1) except: print >>sys.stderr, "---------- Exception while reporting exception ----------" traceback.print_exc() print >>sys.stderr, "------------------ Original exception -------------------" traceback.print_exception(exc_type, exc_val, exc_tb)
def do_alert3(): say("Doing alert3") result = alert3(the_kind(), "Exorcise the haunted pudding factory?") say("Result =", result)