From 835b81a6f866360126a915b49f6a486ea88e20ec Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 2 Jun 2015 11:03:49 -0400 Subject: [PATCH] [MixMaster] Display more useful error messages Include the full text of the original exception, and print this to the terminal as well. --- interfaces/cython/cantera/mixmaster/Edit.py | 4 ++-- interfaces/cython/cantera/mixmaster/main.py | 4 ++-- interfaces/cython/cantera/mixmaster/utilities.py | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/interfaces/cython/cantera/mixmaster/Edit.py b/interfaces/cython/cantera/mixmaster/Edit.py index 2cc8fa3b7..bd87123c6 100644 --- a/interfaces/cython/cantera/mixmaster/Edit.py +++ b/interfaces/cython/cantera/mixmaster/Edit.py @@ -179,8 +179,8 @@ class EditFrame(Frame): try: self.redraw() self.app.makeWindows() - except: - handleError('Edit err') + except Exception as e: + handleError('Edit err:\n'+str(e)) self.app.mix = IdealGasMixture(self.app.mech) self.mix = self.app.mix diff --git a/interfaces/cython/cantera/mixmaster/main.py b/interfaces/cython/cantera/mixmaster/main.py index 16e400c45..987e024c4 100644 --- a/interfaces/cython/cantera/mixmaster/main.py +++ b/interfaces/cython/cantera/mixmaster/main.py @@ -68,9 +68,9 @@ class MixMaster: self.mech = Solution(pathname) self.mechname = ff[0] - except: + except Exception as e: utilities.handleError('could not create gas mixture object: ' - +ff[0]+'\n') + +ff[0]+'\n'+str(e)) self.mechname = 'Error' return diff --git a/interfaces/cython/cantera/mixmaster/utilities.py b/interfaces/cython/cantera/mixmaster/utilities.py index b2ae45d6d..2b752d30f 100644 --- a/interfaces/cython/cantera/mixmaster/utilities.py +++ b/interfaces/cython/cantera/mixmaster/utilities.py @@ -28,6 +28,9 @@ def _print_value(name, value, unitstr): def handleError(message = '', window = None, fatal = 0, warning = 0, options = None): + # Print the message to the terminal, since this can at least be copied and + # pasted, unlike the contents of the dialog box. + print(message) if warning: messagebox.showwarning(title = 'Warning', message = message, parent = window)