diff --git a/src/sas/qtgui/Perspectives/Fitting/FitThread.py b/src/sas/qtgui/Perspectives/Fitting/FitThread.py index 84dfc476f3..a470792e45 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FitThread.py +++ b/src/sas/qtgui/Perspectives/Fitting/FitThread.py @@ -13,10 +13,20 @@ def map_getattr(classInstance, classFunc, *args): Take an instance of a class and a function name as a string. Execute class.function and return result """ - return getattr(classInstance, classFunc)(*args) + try: + return_value = getattr(classInstance, classFunc)(*args) + except Exception as ex: + logger.error("Fitting failed: %s", traceback.format_exc()) + return None + return return_value def map_apply(arguments): - return arguments[0](*arguments[1:]) + try: + return_value = arguments[0](*arguments[1:]) + except Exception as ex: + logger.error("Fitting failed: %s", traceback.format_exc()) + return None + return return_value class FitThread(CalcThread): """Thread performing the fit """ diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py b/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py index 3c48eea4e3..1fbd735bdc 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py @@ -2108,9 +2108,11 @@ def fitComplete(self, result): #re-enable the Fit button self.enableInteractiveElements() - if len(result) == 0: + if not result or not result[0] or not result[0][0]: msg = "Fitting failed." self.communicate.statusBarUpdateSignal.emit(msg) + # reload the kernel_module in case it's corrupted + self.kernel_module = copy.deepcopy(self.kernel_module_copy) return # Don't recalculate chi2 - it's in res.fitness already