diff --git a/Framework/DataHandling/src/SaveNexusProcessed.cpp b/Framework/DataHandling/src/SaveNexusProcessed.cpp index 44d4aea03060e30b59b19f8f9a52e393ba08b5ec..8550239d9628df78c2bd9060e0b115c182050a26 100644 --- a/Framework/DataHandling/src/SaveNexusProcessed.cpp +++ b/Framework/DataHandling/src/SaveNexusProcessed.cpp @@ -588,7 +588,7 @@ bool SaveNexusProcessed::processGroups() { for (size_t entry = 0; entry < workspaces.size(); entry++) { const Workspace_sptr ws = workspaces[entry]; if (ws->isGroup()) { - throw std::runtime_error("SaveNexusProcessed: NeXus files do not " + throw std::runtime_error("NeXus files do not " "support nested groups of groups"); } this->doExec(ws, nexusFile, entry > 0 /*keepFile*/, entry); diff --git a/Framework/PythonInterface/mantid/simpleapi.py b/Framework/PythonInterface/mantid/simpleapi.py index 36e4036f017c1443574e66a5668afeca4dac7eea..f5d48817d31f21de7ac0473edbb9f72fe148c455 100644 --- a/Framework/PythonInterface/mantid/simpleapi.py +++ b/Framework/PythonInterface/mantid/simpleapi.py @@ -138,12 +138,13 @@ def Load(*args, **kwargs): try: algm.setProperty('Filename', filename) # Must be set first except ValueError as ve: - raise ValueError('Problem when setting Filename. This is the detailed error ' - 'description: ' + str(ve) + '\nIf the file has been found ' - 'but you got this error, you might not have read permissions ' - 'or the file might be corrupted.\nIf the file has not been found, ' - 'you might have forgotten to add its location in the data search ' - 'directories.') + msg = 'Problem setting "Filename" in {}-v{}: {}'.format(name, algm.name(), algm.version(), + str(ve)) + raise ValueError(msg + '\nIf the file has been found ' + 'but you got this error, you might not have read permissions ' + 'or the file might be corrupted.\nIf the file has not been found, ' + 'you might have forgotten to add its location in the data search ' + 'directories.') # Remove from keywords so it is not set twice if 'Filename' in kwargs: del kwargs['Filename'] @@ -210,8 +211,8 @@ def StartLiveData(*args, **kwargs): algm.setProperty(name, value) except ValueError as ve: - raise ValueError('Problem when setting %s. This is the detailed error ' - 'description: %s' % (name, str(ve))) + raise ValueError('Problem setting "{}" in {}-v{}: {}'.format(name, algm.name(), + algm.version(), str(ve))) except KeyError: pass # ignore if kwargs[name] doesn't exist @@ -929,10 +930,15 @@ def set_properties(alg_object, *args, **kwargs): def do_set_property(name, new_value): if new_value is None: return - if isinstance(new_value, _kernel.DataItem) and new_value.name(): - alg_object.setPropertyValue(key, new_value.name()) - else: - alg_object.setProperty(key, new_value) + try: + if isinstance(new_value, _kernel.DataItem) and new_value.name(): + alg_object.setPropertyValue(key, new_value.name()) + else: + alg_object.setProperty(key, new_value) + except (RuntimeError, TypeError, ValueError) as e: + msg = 'Problem setting "{}" in {}-v{}: {}'.format(name, alg_object.name(), alg_object.version(), + str(e)) + raise e.__class__(msg) from e # end if len(args) > 0: @@ -1039,7 +1045,8 @@ def _create_algorithm_function(name, version, algm_object): # Check for missing mandatory parameters _check_mandatory_args(name, algm, e, *args, **kwargs) else: - raise + msg = '{}-v{}: {}'.format(algm.name(), algm.version(), str(e)) + raise RuntimeError(msg) from e return _gather_returns(name, lhs, algm) # Set the signature of the callable to be one that is only generated on request. @@ -1131,7 +1138,7 @@ def _create_fake_function(name): # ------------------------------------------------------------------------------------------------ def fake_function(*args, **kwargs): - raise RuntimeError("Mantid import error. The mock simple API functions have not been replaced!" + + raise RuntimeError("Mantid import error. The mock simple API functions have not been replaced!" " This is an error in the core setup logic of the mantid module, " "please contact the development team.") @@ -1164,7 +1171,7 @@ def _mockup(plugins): # ------------------------------------------------------------------------------------------------ def fake_function(*args, **kwargs): - raise RuntimeError("Mantid import error. The mock simple API functions have not been replaced!" + + raise RuntimeError("Mantid import error. The mock simple API functions have not been replaced!" " This is an error in the core setup logic of the mantid module, " "please contact the development team.") diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py index ef03a9c67ebd3940ff9b5d5bdf33eeac8993d7ca..b420096ab5eb68014541d29de165581fa954456e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py @@ -262,7 +262,7 @@ class EnggFitPeaksTest(unittest.TestCase): except RuntimeError as e: error_msg = e.args[0].split("\n")[0] - self.assertEqual(error_msg, "Expected peak centres lie outside the limits of the workspace x axis") + self.assertEqual(error_msg, "EnggFitPeaks-v1: Expected peak centres lie outside the limits of the workspace x axis") def test_expected_peaks_can_be_in_tof(self): """ diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py index dc1a69dd3731098684879dc5550664a42ba4ff9e..2dcbc76ce0066b177eddd86824245c6b502b80c7 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py @@ -30,8 +30,8 @@ class GetEiT0atSNSTest(unittest.TestCase): try: res=GetEiT0atSNS(w,0.1) except Exception as e: - s="Could not get Ei, and this is not a white beam run\nNo peak found for the monitor with spectra num: 2" - self.assertEqual(str(e).find(s),0) + s="GetEiT0atSNS-v1: Could not get Ei, and this is not a white beam run\nNo peak found for the monitor with spectra num: 2" + self.assertTrue(str(e).startswith(s)) DeleteWorkspace(w) diff --git a/Testing/SystemTests/tests/framework/LiquidsReflectometryReductionWithBackgroundTest.py b/Testing/SystemTests/tests/framework/LiquidsReflectometryReductionWithBackgroundTest.py index b1b7b73933fddf52ceef38a2164bffaf0aef0a5d..12416de9d07d8c1070fc7a99460e400191f1c383 100644 --- a/Testing/SystemTests/tests/framework/LiquidsReflectometryReductionWithBackgroundTest.py +++ b/Testing/SystemTests/tests/framework/LiquidsReflectometryReductionWithBackgroundTest.py @@ -203,8 +203,12 @@ class TOFMismatchTest(systemtesting.MantidSystemTest): CropFirstAndLastPoints=False, OutputWorkspace='reflectivity_119816') except RuntimeError as err: - if str(err).startswith("Requested TOF range does not match data"): + msg_exp = "LiquidsReflectometryReduction-v1: Requested TOF range does not match data" + if str(err).startswith(msg_exp): self.correct_exception_caught = True + else: + print("EXPECTED ERROR:", msg_exp) + print("OBSERVED ERROR:", str(err)) def validate(self): return self.correct_exception_caught @@ -244,8 +248,12 @@ class BadDataTOFRangeTest(systemtesting.MantidSystemTest): CropFirstAndLastPoints=False, OutputWorkspace='reflectivity_119816') except RuntimeError as err: - if str(err).startswith("Requested TOF range does not match data"): + msg_exp = "LiquidsReflectometryReduction-v1: Requested TOF range does not match data" + if str(err).startswith(msg_exp): self.correct_exception_caught = True + else: + print("EXPECTED ERROR:", msg_exp) + print("OBSERVED ERROR:", str(err)) def validate(self): return self.correct_exception_caught @@ -284,8 +292,12 @@ class BadPeakSelectionTest(systemtesting.MantidSystemTest): CropFirstAndLastPoints=False, OutputWorkspace='reflectivity_119816') except RuntimeError as err: - if str(err).startswith("The reflectivity is all zeros"): + msg_exp = "LiquidsReflectometryReduction-v1: The reflectivity is all zeros" + if str(err).startswith(msg_exp): self.correct_exception_caught = True + else: + print("EXPECTED ERROR:", msg_exp) + print("OBSERVED ERROR:", str(err)) def validate(self): return self.correct_exception_caught diff --git a/qt/python/mantidqt/project/test/test_workspacesaver.py b/qt/python/mantidqt/project/test/test_workspacesaver.py index fe18900e2ad28147fdbe77cf701aa281609066e6..b02af96ebf852169f954d1487af741658a06aa2c 100644 --- a/qt/python/mantidqt/project/test/test_workspacesaver.py +++ b/qt/python/mantidqt/project/test/test_workspacesaver.py @@ -88,7 +88,7 @@ class WorkspaceSaverTest(unittest.TestCase): ws_saver.save_workspaces(["group2"]) self.assertListEqual(["group1", "group2", "ws1", "ws2", "ws3", "ws4"], ADS.getObjectNames()) - logger.warning.assert_called_with(u'Couldn\'t save workspace in project: "group2" because SaveNexusProcessed: ' + logger.warning.assert_called_with(u'Couldn\'t save workspace in project: "group2" because SaveNexusProcessed-v1: ' u'NeXus files do not support nested groups of groups') def _load_MDWorkspace_and_test_it(self, save_name):