Commit ef7f4c81 authored by David Fairbrother's avatar David Fairbrother
Browse files

Fix various exceptions being copied rather than ref

parent 1f577849
......@@ -307,7 +307,7 @@ void populateTable(ITableWorkspace_sptr &t, const MatrixWorkspace_sptr &ws,
colValues << phi // rtp
<< isMonitorDisplay; // monitor
} catch (std::exception) {
} catch (const std::exception &) {
// spectrumNo=-1, detID=0
colValues << -1 << "0";
// Y/E
......
......@@ -156,7 +156,7 @@ public:
alg->setProperty("IncidentSpecta", IncidentSpecta);
alg->setProperty("InputWorkspace", InputWorkspace);
alg->setProperty("OutputWorkspace", "correction_ws");
TS_ASSERT_THROWS(alg->execute(), std::runtime_error)
TS_ASSERT_THROWS(alg->execute(), const std::runtime_error &)
}
void testCalculatePlaczekSelfScatteringDoesNotRunWithNoSample() {
......@@ -170,7 +170,7 @@ public:
alg->setProperty("IncidentSpecta", IncidentSpecta);
alg->setProperty("InputWorkspace", InputWorkspace);
alg->setProperty("OutputWorkspace", "correction_ws");
TS_ASSERT_THROWS(alg->execute(), std::runtime_error)
TS_ASSERT_THROWS(alg->execute(), const std::runtime_error &)
}
private:
......
......@@ -164,7 +164,7 @@ public:
TS_ASSERT(alg.isInitialized())
TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", inputWS))
TS_ASSERT_THROWS(alg.executeAsChildAlg(), std::runtime_error);
TS_ASSERT_THROWS(alg.executeAsChildAlg(), const std::runtime_error &);
}
};
......
......@@ -477,7 +477,8 @@ public:
IndexPeaks alg;
alg.initialize();
TS_ASSERT_THROWS(alg.setProperty("MaxOrder", -1), std::invalid_argument)
TS_ASSERT_THROWS(alg.setProperty("MaxOrder", -1),
const std::invalid_argument &)
}
void test_modvector_with_list_length_not_three_throws() {
......@@ -485,10 +486,11 @@ public:
alg.initialize();
for (const auto &propName : {"ModVector1", "ModVector2", "ModVector3"}) {
TS_ASSERT_THROWS(alg.setProperty(propName, "0"), std::invalid_argument)
TS_ASSERT_THROWS(alg.setProperty(propName, "0,0"), std::invalid_argument)
TS_ASSERT_THROWS(alg.setProperty(propName, "0"), std::invalid_argument &)
TS_ASSERT_THROWS(alg.setProperty(propName, "0,0"),
std::invalid_argument &)
TS_ASSERT_THROWS(alg.setProperty(propName, "0,0,0,0"),
std::invalid_argument)
std::invalid_argument &)
}
}
......
......@@ -136,7 +136,7 @@ public:
TS_ASSERT_THROWS_NOTHING(alg.setProperty("MinEventsPerFrame", 20));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("MaxEventsPerFrame", 10));
TS_ASSERT_THROWS(alg.execute(), std::runtime_error);
TS_ASSERT_THROWS(alg.execute(), const std::runtime_error &);
}
void test_MinEventsPerFrame_removes_low_values() {
......
......@@ -439,7 +439,7 @@ public:
dir.normalize();
Track track(V3D(-10, 0, 0), dir);
TS_ASSERT_THROWS(geom_obj->distance(track), std::runtime_error)
TS_ASSERT_THROWS(geom_obj->distance(track), const std::runtime_error &)
}
void testTrackTwoIsolatedCubes()
......
......@@ -399,7 +399,7 @@ public:
dir.normalize();
Track track(V3D(-10, 0, 0), dir);
TS_ASSERT_THROWS(geom_obj->distance(track), std::runtime_error)
TS_ASSERT_THROWS(geom_obj->distance(track), const std::runtime_error &)
}
void testTrackTwoIsolatedCubes()
......
......@@ -32,7 +32,7 @@ public:
}
void test_constructor_fail_invalid_instrument() {
TS_ASSERT_THROWS(JSONInstrumentBuilder(""), std::invalid_argument);
TS_ASSERT_THROWS(JSONInstrumentBuilder(""), const std::invalid_argument &);
}
void test_build_geometry() {
......
......@@ -109,7 +109,7 @@ used.
TS_ASSERT_THROWS(NexusGeometrySave::saveInstrument(
instr, destinationFile, DEFAULT_ROOT_ENTRY_NAME,
logger, false /*append*/),
std::invalid_argument);
const std::invalid_argument &);
TS_ASSERT(testing::Mock::VerifyAndClearExpectations(&logger));
}
......
......@@ -204,7 +204,7 @@ void MainWindowPresenter::notifyLoadBatchRequested(int tabIndex) {
QMap<QString, QVariant> map;
try {
map = MantidQt::API::loadJSONFromFile(filename);
} catch (const std::runtime_error) {
} catch (const std::runtime_error &) {
m_messageHandler->giveUserCritical(
"Unable to load requested file. Please load a file of "
"appropriate format saved from the GUI.",
......
......@@ -209,7 +209,7 @@ IndirectFitPropertyBrowser::getFittingFunction() const {
}
return multiDomainFunction;
}
} catch (std::invalid_argument) {
} catch (const std::invalid_argument &) {
return boost::make_shared<MultiDomainFunction>();
}
}
......
......@@ -36,33 +36,35 @@ public:
void testCheckingClipboardTypeThrowsForEmptyClipboard() {
auto clipboard = Clipboard();
TS_ASSERT_THROWS(clipboard.isGroupLocation(0), std::runtime_error);
TS_ASSERT_THROWS(clipboard.isGroupLocation(0), const std::runtime_error &);
}
void testCheckingGroupNameThrowsForEmptyClipboard() {
auto clipboard = Clipboard();
TS_ASSERT_THROWS(clipboard.groupName(0), std::runtime_error);
TS_ASSERT_THROWS(clipboard.groupName(0), const std::runtime_error &);
}
void testSettingGroupNameThrowsForEmptyClipboard() {
auto clipboard = Clipboard();
TS_ASSERT_THROWS(clipboard.setGroupName(0, "test group"),
std::runtime_error);
const std::runtime_error &);
}
void testCreateGroupForRootThrowsForEmptyClipboard() {
auto clipboard = Clipboard();
TS_ASSERT_THROWS(clipboard.createGroupForRoot(0), std::runtime_error);
TS_ASSERT_THROWS(clipboard.createGroupForRoot(0),
const std::runtime_error &);
}
void testCreateRowsForAllRootsThrowsForEmptyClipboard() {
auto clipboard = Clipboard();
TS_ASSERT_THROWS(clipboard.createRowsForAllRoots(), std::runtime_error);
TS_ASSERT_THROWS(clipboard.createRowsForAllRoots(),
const std::runtime_error &);
}
void testContainsGroupsThrowsForEmptyClipboard() {
auto clipboard = Clipboard();
TS_ASSERT_THROWS(containsGroups(clipboard), std::runtime_error);
TS_ASSERT_THROWS(containsGroups(clipboard), const std::runtime_error &);
}
void testClipboardIsInitializedWithRow() {
......@@ -77,18 +79,19 @@ public:
void testGettingGroupNameThrowsForRow() {
auto clipboard = clipboardWithARow();
TS_ASSERT_THROWS(clipboard.groupName(0), std::runtime_error);
TS_ASSERT_THROWS(clipboard.groupName(0), const std::runtime_error &);
}
void testSettingGroupNameThrowsForRow() {
auto clipboard = clipboardWithARow();
TS_ASSERT_THROWS(clipboard.setGroupName(0, "test group"),
std::runtime_error);
const std::runtime_error &);
}
void testCreateGroupForRootThrowsForRow() {
auto clipboard = clipboardWithARow();
TS_ASSERT_THROWS(clipboard.createGroupForRoot(0), std::runtime_error);
TS_ASSERT_THROWS(clipboard.createGroupForRoot(0),
const std::runtime_error &);
}
void testCreateRowsForAllRootsSucceeds() {
......@@ -133,7 +136,8 @@ public:
void testCreateRowsForAllRootsThrowsForGroup() {
auto clipboard = clipboardWithAGroup();
TS_ASSERT_THROWS(clipboard.createRowsForAllRoots(), std::runtime_error);
TS_ASSERT_THROWS(clipboard.createRowsForAllRoots(),
const std::runtime_error &);
}
void testContainsGroupsReturnsTrueIfGroupsExist() {
......@@ -173,7 +177,8 @@ public:
void testCreateRowsForAllRootsThrowsForMultiGroupClipboard() {
auto clipboard = clipboardWithTwoMultiRowGroups();
TS_ASSERT_THROWS(clipboard.createRowsForAllRoots(), std::runtime_error);
TS_ASSERT_THROWS(clipboard.createRowsForAllRoots(),
const std::runtime_error &);
}
void testContainsGroupsReturnsTrueIfMultipleGroupsExist() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment