From a4e37d9ae7e2fc04dcee1558018cbc2aaa88a393 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Fri, 10 Jun 2016 15:07:59 +0200 Subject: [PATCH] Mark certain types of exceptions as fatal and abort the application if they occur We simply cannot recover properly from things like an uncaught MemoryError since that usually means any follow up operation will also fail. So Instead of silently ignoring it and having the application in a broken state we properly abort. Right now the list of fatal exceptions is a bare minimum that contains the most prominent things we cannot recover from. --- cura/CrashHandler.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py index 4efcfbe1e5..e86e407902 100644 --- a/cura/CrashHandler.py +++ b/cura/CrashHandler.py @@ -10,6 +10,17 @@ from UM.Logger import Logger from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") +# List of exceptions that should be considered "fatal" and abort the program. +# These are primarily some exception types that we simply cannot really recover from +# (MemoryError and SystemError) and exceptions that indicate grave errors in the +# code that cause the Python interpreter to fail (SyntaxError, ImportError). +fatal_exception_types = [ + MemoryError, + SyntaxError, + ImportError, + SystemError, +] + def show(exception_type, value, tb): debug_mode = False if QCoreApplication.instance(): @@ -20,7 +31,7 @@ def show(exception_type, value, tb): for part in line.rstrip("\n").split("\n"): Logger.log("c", part) - if not debug_mode: + if not debug_mode and exception_type not in fatal_exception_types: return application = QCoreApplication.instance() @@ -34,7 +45,7 @@ def show(exception_type, value, tb): label = QLabel(dialog) layout.addWidget(label) - label.setText(catalog.i18nc("@label", "

An uncaught exception has occurred!

Please use the information below to post a bug report at http://github.com/Ultimaker/Cura/issues

")) + label.setText(catalog.i18nc("@label", "

A fatal exception has occurred that we could not recover from!

Please use the information below to post a bug report at http://github.com/Ultimaker/Cura/issues

")) textarea = QTextEdit(dialog) layout.addWidget(textarea)