Skip to content

Commit

Permalink
refs #3868. catch exceptions by reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcampbell committed Dec 19, 2011
1 parent 91fe259 commit 2447caf
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void BoundaryConstraint::initialize(API::IFitFunction* fun, const API::Expressio
}
}// if not empty
}
catch(boost::bad_lexical_cast)
catch(boost::bad_lexical_cast &)
{
if ( !parName.empty() )
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/DataHandling/src/LoadRKH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Progress LoadRKH::read2DHeader(const std::string & initalLine, MatrixWorkspace_s
{
nAxis1Boundaries = boost::lexical_cast<int>(fileLine);
}
catch(boost::bad_lexical_cast)
catch(boost::bad_lexical_cast &)
{
// using readNumEntrys() above broke the sequence of getline()s and so try again in case we just read the end of a line
std::getline(m_fileIn, fileLine);
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/DataHandling/src/SaveCanSAS1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ bool SaveCanSAS1D::openForAppending(const std::string & filename)
return true;
}
}
catch (std::fstream::failure)
catch (std::fstream::failure &)
{
g_log.information() << "File " << filename << " couldn't be opened for a appending, will try to create the file\n";
}
Expand Down Expand Up @@ -290,7 +290,7 @@ void SaveCanSAS1D::findEndofLastEntry()
// prepare to write to the place found by reading
m_outFile.seekp(m_outFile.tellg(), std::ios::beg);
}
catch (std::fstream::failure)
catch (std::fstream::failure &)
{
// give users more explaination about no being able to read their files
throw std::logic_error("Trouble reading existing data in the output file, are you appending to an invalid CanSAS1D file?");
Expand All @@ -313,7 +313,7 @@ void SaveCanSAS1D::writeHeader(const std::string & fileName)
createSASRootElement(sasroot);
m_outFile<<sasroot;
}
catch (std::fstream::failure)
catch (std::fstream::failure &)
{
throw Exception::FileError("Error opening the output file for writing", fileName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LoadMaskingFileTest : public CxxTest::TestSuite
DataObjects::SpecialWorkspace2D_sptr maskws =
boost::dynamic_pointer_cast<DataObjects::SpecialWorkspace2D>(AnalysisDataService::Instance().retrieve("PG3Mask"));
}
catch(std::runtime_error e)
catch(std::runtime_error & e)
{
TS_FAIL(e.what());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace Mantid
ObjSurface=new TopoDS_Shape(Result);
BRepMesh::Mesh(Result,0.001);
}
catch(StdFail_NotDone)
catch(StdFail_NotDone &)
{
PLog.error("Cannot build the geometry. Check the geometry definition");
}
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/ICat/src/ICatHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ namespace Mantid
{
saveInvestigationIncludesResponse(response,responsews_sptr);
}
catch(std::runtime_error)
catch(std::runtime_error &)
{
throw std::runtime_error("Error when selecting the investigation data with inestigation id "+ stream.str());
}
Expand Down Expand Up @@ -613,7 +613,7 @@ namespace Mantid
{
saveDataSets(response,responsews_sptr);
}
catch(std::runtime_error)
catch(std::runtime_error &)
{

throw std::runtime_error("Error when loading the datasets for the investigation id "+ stream.str());
Expand Down Expand Up @@ -802,7 +802,7 @@ namespace Mantid
{
throw std::runtime_error("Error when saving the ICat Search Results data to Workspace");
}
catch(std::runtime_error)
catch(std::runtime_error &)
{
throw std::runtime_error("Error when saving the ICat Search Results data to Workspace");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct translate_exception
|| BOOST_WORKAROUND(__GNUC_PATCHLEVEL__, == 3))
catch(exception_non_ref& e)
# else
catch(exception_cref e)
catch(exception_cref & e)
# endif
{
translate(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ double InstrumentActor::getIntegratedCounts(Mantid::detid_t id)const
try {
size_t i = getWorkspaceIndex(id);
return m_specIntegrs.at(i);
} catch (NotFoundError) {
} catch (NotFoundError &) {
// If the detector is not represented in the workspace
return -1.0;
}
Expand All @@ -263,7 +263,7 @@ void InstrumentActor::resetColors()
m_colors[wi] = GLColor(qRed(color), qGreen(color), qBlue(color));
}
}
catch(NotFoundError)
catch(NotFoundError &)
{
m_colors[wi] = m_failedColor;
continue;
Expand All @@ -288,7 +288,7 @@ GLColor InstrumentActor::getColor(Mantid::detid_t id)const
try {
size_t i = getWorkspaceIndex(id);
return m_colors.at(i);
} catch (NotFoundError) {
} catch (NotFoundError &) {
// Return the first color if the detector is not represented in the workspace
return m_colors.front();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ void InstrumentWindow::spectraInfoDialog()
QString wsIndex;
try {
wsIndex = QString::number(m_instrumentActor->getWorkspaceIndex(m_selectedDetectors.front()));
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
// Detector doesn't have a workspace index relating to it
wsIndex = "None";
}
Expand All @@ -416,7 +416,7 @@ void InstrumentWindow::spectraInfoDialog()
{
try {
wksp_indices.push_back(m_instrumentActor->getWorkspaceIndex(m_selectedDetectors[i]));
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand All @@ -437,7 +437,7 @@ void InstrumentWindow::plotSelectedSpectra()
{
try {
indices.insert(int(m_instrumentActor->getWorkspaceIndex(m_selectedDetectors[i])));
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand All @@ -455,7 +455,7 @@ void InstrumentWindow::showDetectorTable()
{
try {
indexes.push_back(int(m_instrumentActor->getWorkspaceIndex(m_selectedDetectors[i])));
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand Down Expand Up @@ -501,7 +501,7 @@ void InstrumentWindow::groupDetectors()
{
try {
wksp_indices.push_back(int(m_instrumentActor->getWorkspaceIndex(m_selectedDetectors[i])));
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand All @@ -527,7 +527,7 @@ void InstrumentWindow::maskDetectors()
{
try {
wksp_indices.push_back(int(m_instrumentActor->getWorkspaceIndex(m_selectedDetectors[i])));
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void InstrumentWindowMaskTab::applyMask()
{
try {
detList << QString::number(m_instrumentWindow->getInstrumentActor()->getWorkspaceIndex(id));
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand Down Expand Up @@ -428,7 +428,7 @@ Mantid::API::MatrixWorkspace_sptr InstrumentWindowMaskTab::createMaskWorkspace(b
try {
size_t wi = m_instrumentWindow->getInstrumentActor()->getWorkspaceIndex(id);
outputWS->maskWorkspaceIndex(wi);
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void InstrumentWindowPickTab::updateSelectionInfo(int detid)
try {
wsIndex = QString::number(instrActor->getWorkspaceIndex(detid));
updatePlot(detid); // Update the plot if the detector links to some data
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
// Detector doesn't have a workspace index relating to it
wsIndex = "None";
m_plot->clearCurve(); // Clear the plot window
Expand Down Expand Up @@ -846,7 +846,7 @@ void InstrumentWindowPickTab::prepareDataForSinglePlot(
size_t wi;
try {
wi = instrActor->getWorkspaceIndex(detid);
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
return; // Detector doesn't have a workspace index relating to it
}
// get the data
Expand Down Expand Up @@ -895,7 +895,7 @@ void InstrumentWindowPickTab::prepareDataForSumsPlot(
size_t wi;
try {
wi = instrActor->getWorkspaceIndex(detid);
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
return; // Detector doesn't have a workspace index relating to it
}
size_t imin,imax;
Expand Down Expand Up @@ -933,7 +933,7 @@ void InstrumentWindowPickTab::prepareDataForSumsPlot(
std::transform(tmp.begin(),tmp.end(),tmp.begin(),tmp.begin(),std::multiplies<double>());
std::transform(err->begin(),err->end(),tmp.begin(),err->begin(),std::plus<double>());
}
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand Down Expand Up @@ -972,7 +972,7 @@ void InstrumentWindowPickTab::prepareDataForIntegralsPlot(
size_t wi;
try {
wi = instrActor->getWorkspaceIndex(detid);
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
return; // Detector doesn't have a workspace index relating to it
}
// imin and imax give the bin integration range
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void InstrumentWindowPickTab::prepareDataForIntegralsPlot(
// take sqrt
errmap[xvalue] = sqrt(sum);
}
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
continue; // Detector doesn't have a workspace index relating to it
}
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Mantid/MantidDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ bool MantidTreeWidgetItem::operator<(const QTreeWidgetItem &other)const
{
return false;
}
} catch (Mantid::Kernel::Exception::NotFoundError nfe)
} catch (Mantid::Kernel::Exception::NotFoundError & nfe)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Mantid/MantidMDCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void MantidMDCurve::dataReset(const QString& wsName)
setStyle(QwtPlotCurve::Lines);
// Queue this plot to be updated once all MantidQwtIMDWorkspaceData objects for this workspace have been
emit dataUpdated();
} catch(std::range_error) {
} catch(std::range_error &) {
// Get here if the new workspace has fewer spectra and the plotted one no longer exists
Mantid::Kernel::Logger::get("MantidMDCurve").information() << "Workspace " << wsNameStd
<< " now has fewer spectra - plotted curve(s) deleted\n";
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Mantid/MantidMatrixCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void MantidMatrixCurve::dataReset(const QString& wsName)
}
// Queue this plot to be updated once all MantidQwtMatrixWorkspaceData objects for this workspace have been
emit dataUpdated();
} catch(std::range_error) {
} catch(std::range_error &) {
// Get here if the new workspace has fewer spectra and the plotted one no longer exists
Mantid::Kernel::Logger::get("MantidMatrixCurve").information() << "Workspace " << wsNameStd
<< " now has fewer spectra - plotted curve(s) deleted\n";
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ void MantidUI::getSelectedAlgorithm(QString& algName, int& version)
algName = QString::fromStdString(alg->name());
version = alg->version();
}
catch ( std::runtime_error ) // not found
catch ( std::runtime_error &) // not found
{
algName = "";
version = -99;
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/MantidPlot/src/Mantid/MantidWSIndexDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void MantidWSIndexDialog::plot()
accept();
}
}
catch (std::exception)
catch (std::exception &)
{
// Text could not be parsed. Probably dont need this as we only
// parse "QValidator::Acceptable" fields anyway ...
Expand Down Expand Up @@ -705,7 +705,7 @@ bool IntervalList::isParsable(const QString &input, const IntervalList &containe
const IntervalList test(input);
return container.contains(test);
}
catch (std::exception e)
catch (std::exception & e)
{
return false;
}
Expand All @@ -718,7 +718,7 @@ bool IntervalList::isParsable(const QString &input)
new IntervalList(input);
return true;
}
catch (std::exception e)
catch (std::exception & e)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/MultiLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ void MultiLayer::dropOntoMatrixCurve(Graph *g, MantidMatrixCurve* originalCurve,
{
try {
new MantidMatrixCurve(it.key(),g,(*setIt),errorBars);
} catch (Mantid::Kernel::Exception::NotFoundError) {
} catch (Mantid::Kernel::Exception::NotFoundError &) {
// Get here if workspace name is invalid - shouldn't be possible, but just in case
} catch (std::invalid_argument&) {
// Get here if invalid spectrum number given - shouldn't be possible, but just in case
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ bool SANSRunWindow::handleLoadButtonClick()
readNumberOfEntries("can_trans_load.direct", m_uiForm.dirCan);
}
}
catch(std::runtime_error)
catch(std::runtime_error &)
{//the user should already have seen an error message box pop up
g_log.error() << "Problem loading file\n";
is_loaded = false;
Expand Down Expand Up @@ -2634,7 +2634,7 @@ void SANSRunWindow::checkList()
valid = true;
}
}
catch (boost::bad_lexical_cast)
catch (boost::bad_lexical_cast &)
{// there is a problem with the input somewhere
valid = false;
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidQt/MantidWidgets/src/SaveWorkspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void SaveWorkspaces::saveSel()
saveCommands += saveList(m_workspaces->selectedItems(), i.value(),
m_fNameEdit->text(), toAppend);
}
catch(std::logic_error)
catch(std::logic_error &)
{
QMessageBox::information(this, "No workspace to save", "You must select at least one workspace to save");
return;
Expand Down

0 comments on commit 2447caf

Please sign in to comment.