From 7e0995ca25aa38d267cb6efb95d87d111c85b080 Mon Sep 17 00:00:00 2001 From: Agnieszka Kostrzewa Date: Wed, 14 Mar 2012 14:00:49 +0100 Subject: [PATCH] Added stacktrace to critical exception message box. --- qubesmanager/main.py | 28 +++++++++++++++++++++------- qubesmanager/settings.py | 27 +++++++++++++++++++++------ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/qubesmanager/main.py b/qubesmanager/main.py index c6b80bc..36b711c 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -1382,14 +1382,28 @@ def handle_exception( exc_type, exc_value, exc_traceback ): filename = os.path.basename( filename ) error = "%s: %s" % ( exc_type.__name__, exc_value ) - QMessageBox.critical(None, "Houston, we have a problem...", - "Whoops. A critical error has occured. This is most likely a bug " - "in Qubes Manager.

" - "%s" % error + - "at line %d of file %s.

" - % ( line, filename )) + strace = "" + stacktrace = traceback.extract_tb( exc_traceback ) + while len(stacktrace) > 0: + (filename, line, func, txt) = stacktrace.pop() + strace += "----\n" + strace += "line: %s\n" %txt + strace += "func: %s\n" %func + strace += "line no.: %d\n" %line + strace += "file: %s\n" %filename + + msg_box = QMessageBox() + msg_box.setDetailedText(strace) + msg_box.setIcon(QMessageBox.Critical) + msg_box.setWindowTitle( "Houston, we have a problem...") + msg_box.setText("Whoops. A critical error has occured. This is most likely a bug " + "in Qubes Manager.

" + "%s" % error + + "
at line %d
of file %s.

" + % ( line, filename )) + + msg_box.exec_() - #sys.exit(1) def main(): diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 470d6fd..e21aff3 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -630,12 +630,27 @@ def handle_exception( exc_type, exc_value, exc_traceback ): filename = os.path.basename( filename ) error = "%s: %s" % ( exc_type.__name__, exc_value ) - QMessageBox.critical(None, "Houston, we have a problem...", - "Whoops. A critical error has occured. This is most likely a bug " - "in Qubes VM Settings application.

" - "%s" % error + - "at line %d of file %s.

" - % ( line, filename )) + strace = "" + stacktrace = traceback.extract_tb( exc_traceback ) + while len(stacktrace) > 0: + (filename, line, func, txt) = stacktrace.pop() + strace += "----\n" + strace += "line: %s\n" %txt + strace += "func: %s\n" %func + strace += "line no.: %d\n" %line + strace += "file: %s\n" %filename + + msg_box = QMessageBox() + msg_box.setDetailedText(strace) + msg_box.setIcon(QMessageBox.Critical) + msg_box.setWindowTitle( "Houston, we have a problem...") + msg_box.setText("Whoops. A critical error has occured. This is most likely a bug " + "in Qubes Manager.

" + "%s" % error + + "
at line %d
of file %s.

" + % ( line, filename )) + + msg_box.exec_() def main():