mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 22:54:01 -06:00
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.
This commit is contained in:
parent
44f8744c84
commit
a4e37d9ae7
1 changed files with 13 additions and 2 deletions
|
@ -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", "<p>An uncaught exception has occurred!</p><p>Please use the information below to post a bug report at <a href=\"http://github.com/Ultimaker/Cura/issues\">http://github.com/Ultimaker/Cura/issues</a></p>"))
|
||||
label.setText(catalog.i18nc("@label", "<p>A fatal exception has occurred that we could not recover from!</p><p>Please use the information below to post a bug report at <a href=\"http://github.com/Ultimaker/Cura/issues\">http://github.com/Ultimaker/Cura/issues</a></p>"))
|
||||
|
||||
textarea = QTextEdit(dialog)
|
||||
layout.addWidget(textarea)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue