def wrapper (*args, **kwargs): try: return func (*args, **kwargs) except: errors_log_fatal_error (domain, "Fatal exception in callback; exiting main loop") debuglog.debug_log_current_exception (domain) gtk.main_quit ()
def errors_log_recoverable_exception (domain, msg): """Reports the current exception to the debug log (see debuglog), and records the presence of a recoverable error. This condition can be checked later with errors_have_recoverable_error(). @domain: name of debug log domain @msg: message to print to the debug log in addition to the current exception""" errors_log_recoverable_error (domain, msg) debuglog.debug_log_current_exception (domain)
def errors_exit_with_fatal_exception (domain, log_config_filename): """Exits the program when a fatal exception has occurred. First, this logs the current exception to the debug log. Then, it dumps the debug log to stderr and exits the program with exit code util.EXIT_CODE_FATAL. @domain: name of debug log domain @log_config_filename: File to mention in the debug log as the source for its configuration Return value: this function does not return, as it exits the program.""" debuglog.debug_log (True, domain, "Fatal exception! Exiting abnormally.") debuglog.debug_log_current_exception (domain) debuglog.debug_log_dump_to_file (log_config_filename, sys.stderr) sys.exit (util.EXIT_CODE_FATAL)