diff --git a/GUI/Model/Data/DataItem.cpp b/GUI/Model/Data/DataItem.cpp index f1b24d072be292e892a271ae4e195f36092c4f64..d73cc03351785dd1ff4b47809d167fc2ff552490 100644 --- a/GUI/Model/Data/DataItem.cpp +++ b/GUI/Model/Data/DataItem.cpp @@ -19,7 +19,6 @@ #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" #include "GUI/Support/Util/CoordName.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/Util/MessageService.h" #include "GUI/Support/XML/UtilXML.h" #include <QFile> @@ -66,8 +65,8 @@ void DataItem::setDatafield(Datafield* data) void DataItem::setRawDataVector(const std::vector<double>& data) { if (m_datafield->size() != data.size()) - throw Error("DataItem::setVector -> Error. " - "Different data size."); + throw std::runtime_error("DataItem::setVector -> Error. " + "Different data size."); std::unique_lock<std::mutex> lock(m_update_data_mutex); m_datafield->setVector(data); diff --git a/GUI/Model/Data/IntensityDataItem.cpp b/GUI/Model/Data/IntensityDataItem.cpp index da2420ffa77c33a728dd34427e407331518f00a1..3db11c0e9004a902e023dff984ee4b20898397eb 100644 --- a/GUI/Model/Data/IntensityDataItem.cpp +++ b/GUI/Model/Data/IntensityDataItem.cpp @@ -24,7 +24,6 @@ #include "GUI/Model/Data/ProjectionItems.h" #include "GUI/Support/IO/ImportDataInfo.h" #include "GUI/Support/Util/CoordName.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/Util/QCP_Util.h" #include <qcustomplot.h> diff --git a/GUI/Model/Data/SpecularDataItem.cpp b/GUI/Model/Data/SpecularDataItem.cpp index 86b240c0d36eb05abcf1146266f5173305024f62..8a535d31e535f17d148192d9522cb8283cf51a41 100644 --- a/GUI/Model/Data/SpecularDataItem.cpp +++ b/GUI/Model/Data/SpecularDataItem.cpp @@ -21,7 +21,6 @@ #include "GUI/Model/Axis/BasicAxisItem.h" #include "GUI/Model/Data/DataItemUtil.h" #include "GUI/Support/IO/ImportDataInfo.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/XML/UtilXML.h" namespace { diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp index eb2001676744c6a6f1dfc536aba4385d8d8403c1..46e4a51c9423181e8e7f9cd828928750f366e8f0 100644 --- a/GUI/Model/Device/InstrumentItems.cpp +++ b/GUI/Model/Device/InstrumentItems.cpp @@ -38,7 +38,6 @@ #include "GUI/Model/Device/RealItem.h" #include "GUI/Model/Sample/SampleItem.h" #include "GUI/Support/Util/CoordName.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/XML/Backup.h" #include "Param/Distrib/Distributions.h" #include "Sample/Multilayer/MultiLayer.h" @@ -376,7 +375,7 @@ std::vector<int> SpecularInstrumentItem::shape() const void SpecularInstrumentItem::updateToRealData(const RealItem* item) { if (shape().size() != item->shape().size()) - throw Error("Specular instrument type is incompatible with passed data shape"); + throw std::runtime_error("Specular instrument type is incompatible with passed data shape"); const auto& data = item->nativeDatafield()->axis(0); std::unique_ptr<const ICoordSystem> converter = createCoordSystem(); @@ -602,9 +601,9 @@ void OffspecInstrumentItem::updateToRealData(const RealItem* dataItem) const auto data_shape = dataItem->shape(); if (shape().size() != data_shape.size()) - throw Error("Offspec instrument type is incompatible with passed data shape"); + throw std::runtime_error("Offspec instrument type is incompatible with passed data shape"); - throw Error("OffspecInstrumentItem::updateToRealData not yet implemented"); + throw std::runtime_error("OffspecInstrumentItem::updateToRealData not yet implemented"); // ... set to data_shape[0] detectorItem()->setYSize(data_shape[1]); @@ -706,7 +705,7 @@ void GISASInstrumentItem::updateToRealData(const RealItem* item) const auto data_shape = item->shape(); if (shape().size() != data_shape.size()) - throw Error("GISAS instrument type is incompatible with passed data shape."); + throw std::runtime_error("GISAS instrument type is incompatible with passed data shape."); detectorItem()->setXSize(data_shape[0]); detectorItem()->setYSize(data_shape[1]); } diff --git a/GUI/Model/Device/RealItem.cpp b/GUI/Model/Device/RealItem.cpp index 7d46a0c2fca136ef6a8ba52e9bb781b2568c2c22..a8abf693a1d60b7892a08a7a70e00f348372854a 100644 --- a/GUI/Model/Device/RealItem.cpp +++ b/GUI/Model/Device/RealItem.cpp @@ -25,7 +25,6 @@ #include "GUI/Support/IO/DataLoaders1D.h" #include "GUI/Support/IO/ImportDataInfo.h" #include "GUI/Support/IO/ItemFileNameUtil.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/XML/Backup.h" #include "GUI/Support/XML/DeserializationException.h" @@ -57,8 +56,8 @@ void initDataItem(const std::size_t rank, std::unique_ptr<DataItem>& dataItem) if (dataItem) { if ((rank == 1 && !dynamic_cast<const SpecularDataItem*>(dataItem.get())) || (rank == 2 && !dynamic_cast<const IntensityDataItem*>(dataItem.get()))) - throw Error("Error in RealItem::initDataItem: trying to set data " - "incompatible with underlying data item"); + throw std::runtime_error("Error in RealItem::initDataItem: trying to set data " + "incompatible with underlying data item"); } else { if (rank == 1) dataItem = std::make_unique<SpecularDataItem>(); diff --git a/GUI/Model/FromCore/ItemizeSimulation.cpp b/GUI/Model/FromCore/ItemizeSimulation.cpp index 8096b62a4ad937f2e251de841c3cfa1fbc934175..8ae4f59f259345e628456e26cf42b81373879c60 100644 --- a/GUI/Model/FromCore/ItemizeSimulation.cpp +++ b/GUI/Model/FromCore/ItemizeSimulation.cpp @@ -40,7 +40,6 @@ #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Device/InstrumentModel.h" #include "GUI/Support/Data/SimulationOptionsItem.h" -#include "GUI/Support/Util/Error.h" #include "Param/Distrib/Distributions.h" #include "Resample/Options/SimulationOptions.h" #include "Sim/Background/ConstantBackground.h" @@ -119,7 +118,8 @@ void setMaskContainer(MaskContainerItem* destMaskItems, const IDetector& detecto } else - throw Error("Cannot convert detector mask from core to GUI: Unknown shape"); + throw std::runtime_error( + "Cannot convert detector mask from core to GUI: Unknown shape"); } if (detector.hasExplicitRegionOfInterest()) { @@ -308,8 +308,8 @@ void setDetectorResolution(DetectorItem* detector_item, const IDetector& detecto item->setSigmaX(scale * resfunc->sigmaX()); item->setSigmaY(scale * resfunc->sigmaY()); } else { - throw Error("setDetectorResolution -> Error. " - "Unknown detector resolution function"); + throw std::runtime_error("setDetectorResolution -> Error. " + "Unknown detector resolution function"); } } else ASSERT(false); diff --git a/GUI/Model/Job/FitParameterContainerItem.cpp b/GUI/Model/Job/FitParameterContainerItem.cpp index 30273f6c5cff413f14c456efa7a32e9b22e0a4e6..dc27bed1e27867d92782f98fb18bbe3fc84c119e 100644 --- a/GUI/Model/Job/FitParameterContainerItem.cpp +++ b/GUI/Model/Job/FitParameterContainerItem.cpp @@ -16,7 +16,6 @@ #include "Base/Util/Assert.h" #include "Fit/Param/Parameters.h" #include "GUI/Model/Job/ParameterTreeItems.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/XML/UtilXML.h" namespace { @@ -162,12 +161,12 @@ mumufit::Parameters FitParameterContainerItem::createParameters() const int index(0); for (auto* fitPar : fitParameterItems()) { - if (!fitPar->isValid()) { - throw Error( + if (!fitPar->isValid()) + throw std::runtime_error( QString("FitParameterContainerItem::createParameters(): invalid starting value " "or (min, max) range in fitting parameter par %1") - .arg(index)); - } + .arg(index) + .toLatin1()); double startValue = fitPar->startValue(); AttLimits limits = fitPar->attLimits(); QString name = QString("par%1").arg(index); diff --git a/GUI/Model/Job/FitSuiteItem.cpp b/GUI/Model/Job/FitSuiteItem.cpp index 76862fc05e5d3309f0fb2071fabef027d32341f0..eaca99ba55e0c499e5fd1488f341b8aa255808be 100644 --- a/GUI/Model/Job/FitSuiteItem.cpp +++ b/GUI/Model/Job/FitSuiteItem.cpp @@ -15,7 +15,6 @@ #include "GUI/Model/Job/FitSuiteItem.h" #include "GUI/Model/Job/FitParameterContainerItem.h" #include "GUI/Model/Job/MinimizerItem.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/XML/UtilXML.h" namespace { @@ -42,8 +41,9 @@ FitSuiteItem::FitSuiteItem() FitParameterContainerItem* FitSuiteItem::createFitParametersContainerItem() { if (m_fitContainer) - throw Error("FitSuiteItem::createFitParametersContainer -> Error. Attempt to create " - "a second FitParameterContainer."); + throw std::runtime_error( + "FitSuiteItem::createFitParametersContainer -> Error. Attempt to create " + "a second FitParameterContainer."); m_fitContainer = std::make_unique<FitParameterContainerItem>(); return m_fitContainer.get(); @@ -57,8 +57,9 @@ FitParameterContainerItem* FitSuiteItem::fitParameterContainerItem() MinimizerContainerItem* FitSuiteItem::createMinimizerContainerItem() { if (m_minimizerContainer) - throw Error("FitSuiteItem::createMinimizerContainer -> Error. Attempt to create " - "a second MinimizerContainer."); + throw std::runtime_error( + "FitSuiteItem::createMinimizerContainer -> Error. Attempt to create " + "a second MinimizerContainer."); m_minimizerContainer = std::make_unique<MinimizerContainerItem>(); return m_minimizerContainer.get(); diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index a6fe5919cc0f81171ffd6a93819b87ac1316f25d..462e2a80035f89579979fa92e2fb87f973398fb5 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -28,7 +28,6 @@ #include "GUI/Model/Job/ParameterTreeItems.h" #include "GUI/Model/Sample/SampleItem.h" #include "GUI/Support/IO/ItemFileNameUtil.h" -#include "GUI/Support/Util/Error.h" #include <stdexcept> // domain_error namespace { @@ -250,7 +249,7 @@ FitSuiteItem* JobItem::fitSuiteItem() FitSuiteItem* JobItem::createFitSuiteItem() { if (m_fitSuiteItem) - throw Error("Will not create a second FitSuiteItem."); + throw std::runtime_error("Will not create a second FitSuiteItem."); m_fitSuiteItem = std::make_unique<FitSuiteItem>(); return m_fitSuiteItem.get(); diff --git a/GUI/Model/Model/JobModel.cpp b/GUI/Model/Model/JobModel.cpp index 9e21072fa9e25cd20c9ff879b6e4ab58979eff65..6858b32f13e34ac91eb840e95199786bbc8a716c 100644 --- a/GUI/Model/Model/JobModel.cpp +++ b/GUI/Model/Model/JobModel.cpp @@ -18,7 +18,6 @@ #include "GUI/Model/Job/ParameterTreeItems.h" #include "GUI/Model/Model/ParameterTreeUtil.h" #include "GUI/Model/Sample/SampleItem.h" -#include "GUI/Support/Util/Error.h" namespace { namespace Tag { @@ -177,7 +176,7 @@ void JobModel::readFrom(QXmlStreamReader* r) } if (r->hasError()) - throw Error(r->errorString()); + throw std::runtime_error(r->errorString().toLatin1()); } void JobModel::writeDataFiles(const QString& projectDir) diff --git a/GUI/Model/Model/JobQueueData.cpp b/GUI/Model/Model/JobQueueData.cpp index 1490555ecaa299abc634224d4dc1c09e67b7f450..39f7404b783214f908857d62f777b3a937c24311 100644 --- a/GUI/Model/Model/JobQueueData.cpp +++ b/GUI/Model/Model/JobQueueData.cpp @@ -17,7 +17,6 @@ #include "GUI/Model/Model/JobModel.h" #include "GUI/Model/ToCore/SimulationToCore.h" #include "GUI/Support/Data/JobWorker.h" -#include "GUI/Support/Util/Error.h" #include "Sim/Simulation/ISimulation.h" #include <QThread> @@ -40,7 +39,7 @@ void JobQueueData::runJob(JobItem* jobItem) return; if (getSimulation(identifier)) - throw Error("JobQueueData::runJob -> Error. ISimulation is already existing."); + throw std::runtime_error("JobQueueData::runJob -> Error. ISimulation is already existing."); try { auto simulation = GUI::ToCore::itemsToSimulation( @@ -188,7 +187,7 @@ void JobQueueData::assignForDeletion(QThread* thread) } } - throw Error("JobQueueData::assignForDeletion -> Error! Cannot find thread."); + throw std::runtime_error("JobQueueData::assignForDeletion -> Error! Cannot find thread."); } //! Removes JobRunner from the map of known runners, assigns it for deletion. @@ -205,7 +204,7 @@ void JobQueueData::assignForDeletion(JobWorker* worker) } } - throw Error("JobQueueData::assignForDeletion -> Error! Cannot find the runner."); + throw std::runtime_error("JobQueueData::assignForDeletion -> Error! Cannot find the runner."); } void JobQueueData::clearSimulation(const QString& identifier) diff --git a/GUI/Model/Model/RealModel.cpp b/GUI/Model/Model/RealModel.cpp index b91a3ae18e58ef37ac69713b390d7947474c7ea8..9299fcd91669d0a7d5505464aa427d9617dfe4be 100644 --- a/GUI/Model/Model/RealModel.cpp +++ b/GUI/Model/Model/RealModel.cpp @@ -15,7 +15,6 @@ #include "GUI/Model/Model/RealModel.h" #include "Base/Util/Assert.h" #include "GUI/Model/Device/RealItem.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/XML/UtilXML.h" namespace { @@ -108,7 +107,7 @@ void RealModel::readFrom(QXmlStreamReader* r) } if (r->hasError()) - throw Error(r->errorString()); + throw std::runtime_error(r->errorString().toLatin1()); } void RealModel::writeDataFiles(const QString& projectDir) diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index 1d641bddb9a6362244f8b6815f8224927461ae77..30292212d3c5c3d5c69b283a84739ae814a5071d 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -21,7 +21,6 @@ #include "GUI/Model/Sample/SampleItem.h" #include "GUI/Support/Data/ID.h" #include "GUI/Support/IO/ProjectUtil.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/Util/MessageService.h" #include "GUI/Support/Util/Path.h" #include "GUI/Support/XML/DeserializationException.h" @@ -157,9 +156,8 @@ void ProjectDocument::saveProjectFileWithData(const QString& projectPullPath) { QFile file(projectPullPath); if (!file.open(QFile::ReadWrite | QIODevice::Truncate | QFile::Text)) - throw Error("ProjectDocument::save_project_file -> Error. Cannot open " - "file '" - + projectPullPath + "' for writing."); + throw std::runtime_error("Cannot open project file '" + projectPullPath.toLatin1() + + "' for writing."); writeProject(&file); file.close(); diff --git a/GUI/Model/Sample/CoreAndShellItem.cpp b/GUI/Model/Sample/CoreAndShellItem.cpp index 1aebae1e426e2bfd0911b014aa432f16504e01c0..c40c84253236c91503c13197bbe835f004add239 100644 --- a/GUI/Model/Sample/CoreAndShellItem.cpp +++ b/GUI/Model/Sample/CoreAndShellItem.cpp @@ -17,7 +17,6 @@ #include "GUI/Model/Sample/MaterialModel.h" #include "GUI/Model/Sample/ParticleItem.h" #include "GUI/Support/Type/VariantUtil.h" -#include "GUI/Support/Util/Error.h" #include "Sample/Particle/CoreAndShell.h" #include "Sample/Particle/Particle.h" #include "Sample/Scattering/Rotations.h" diff --git a/GUI/Model/Sample/MesocrystalItem.cpp b/GUI/Model/Sample/MesocrystalItem.cpp index 534af1b427e8870f14328ebedf1ad25d85b7d8f9..c3b2e7a871333cde2250b48d29dbcd7aa38024f6 100644 --- a/GUI/Model/Sample/MesocrystalItem.cpp +++ b/GUI/Model/Sample/MesocrystalItem.cpp @@ -17,7 +17,6 @@ #include "GUI/Model/Sample/CoreAndShellItem.h" #include "GUI/Model/Sample/FormFactorItems.h" #include "GUI/Model/Sample/ParticleItem.h" -#include "GUI/Support/Util/Error.h" #include "Sample/Particle/CoreAndShell.h" #include "Sample/Particle/Crystal.h" #include "Sample/Particle/IFormFactor.h" @@ -154,18 +153,18 @@ std::unique_ptr<Mesocrystal> MesocrystalItem::createMesocrystal() const { const Lattice3D& lattice = getLattice(); if (!(lattice.unitCellVolume() > 0.0)) - throw Error("MesocrystalItem::createMesocrystal(): " - "Lattice volume not strictly positive"); + throw std::runtime_error("MesocrystalItem::createMesocrystal(): " + "Lattice volume not strictly positive"); std::unique_ptr<IParticle> basis = getBasis(); if (!basis) - throw Error("MesocrystalItem::createMesocrystal(): " - "No basis particle defined"); + throw std::runtime_error("MesocrystalItem::createMesocrystal(): " + "No basis particle defined"); Crystal crystal(*basis, lattice); std::unique_ptr<IFormFactor> ff = getOuterShape(); if (!ff) - throw Error("MesocrystalItem::createMesocrystal(): " - "No outer shape defined"); + throw std::runtime_error("MesocrystalItem::createMesocrystal(): " + "No outer shape defined"); auto result = std::make_unique<Mesocrystal>(crystal, *ff); if (auto r = createRotation(); r && !r->isIdentity()) diff --git a/GUI/Model/ToCore/SampleToCore.cpp b/GUI/Model/ToCore/SampleToCore.cpp index fd27fbbd5fd76cbd52f2c7201793fd980b3b5fe5..bdc7a280a735a9dc6ac225aca1d43193b1e66edd 100644 --- a/GUI/Model/ToCore/SampleToCore.cpp +++ b/GUI/Model/ToCore/SampleToCore.cpp @@ -24,7 +24,6 @@ #include "GUI/Model/Sample/ParticleLayoutItem.h" #include "GUI/Model/Sample/RoughnessItems.h" #include "GUI/Model/Sample/SampleItem.h" -#include "GUI/Support/Util/Error.h" #include "Sample/Aggregate/IInterference.h" #include "Sample/Aggregate/ParticleLayout.h" #include "Sample/Interface/LayerRoughness.h" diff --git a/GUI/Support/IO/ImportDataInfo.cpp b/GUI/Support/IO/ImportDataInfo.cpp index 9f9306fab85ac993dcaaf00ae691ff530dddb640..5d20dbda93e2ec2bb317bfc1e6d433664246a3ac 100644 --- a/GUI/Support/IO/ImportDataInfo.cpp +++ b/GUI/Support/IO/ImportDataInfo.cpp @@ -18,7 +18,6 @@ #include "Device/Coord/CoordSystem1D.h" #include "Device/Data/Datafield.h" #include "GUI/Support/Util/CoordName.h" -#include "GUI/Support/Util/Error.h" #include <map> ImportDataInfo::ImportDataInfo(ImportDataInfo&& other) @@ -90,7 +89,7 @@ QString ImportDataInfo::axisLabel(size_t axis_index) const return "Signal [a.u.]"; return QString::fromStdString(AngularReflectometryCoords::nameOfAxis0(m_coords)); } - throw Error("Error in ImportDataInfo::axisLabel: unsupported data type"); + throw std::runtime_error("Error in ImportDataInfo::axisLabel: unsupported data type"); } void ImportDataInfo::checkValidity() @@ -102,10 +101,10 @@ void ImportDataInfo::checkValidity() return; auto iter = available_units.find(m_data->rank()); if (iter == available_units.end()) - throw Error("Error in ImportDataInfo constructor: unsupported data type"); + throw std::runtime_error("Error in ImportDataInfo constructor: unsupported data type"); for (auto& value : iter->second) if (m_coords == value) return; - throw Error("Error in ImportDataInfo constructor: inacceptable units passed."); + throw std::runtime_error("Error in ImportDataInfo constructor: inacceptable units passed."); } diff --git a/GUI/Support/Util/Error.cpp b/GUI/Support/Util/Error.cpp deleted file mode 100644 index 8c0bbe79e9a6bbf71845df3c95869624f73ca90b..0000000000000000000000000000000000000000 --- a/GUI/Support/Util/Error.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Support/Util/Error.cpp -//! @brief Implements Error class -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/Support/Util/Error.h" - -Error::Error(const QString& message) - : m_messageAsLatin1(message.toLatin1()) -{ -} - -const char* Error::what() const noexcept -{ - return m_messageAsLatin1.data(); -} diff --git a/GUI/Support/Util/Error.h b/GUI/Support/Util/Error.h deleted file mode 100644 index dc0349d15c0ccb9625cfa318d2400134de854f1e..0000000000000000000000000000000000000000 --- a/GUI/Support/Util/Error.h +++ /dev/null @@ -1,30 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Support/Util/Error.h -//! @brief Defines error class -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_SUPPORT_UTIL_ERROR_H -#define BORNAGAIN_GUI_SUPPORT_UTIL_ERROR_H - -#include <QByteArray> -#include <QString> - -class Error : public std::exception { -public: - explicit Error(const QString& message); - const char* what() const noexcept override; - -private: - QByteArray m_messageAsLatin1; -}; - -#endif // BORNAGAIN_GUI_SUPPORT_UTIL_ERROR_H diff --git a/GUI/View/Fit/FitSessionController.cpp b/GUI/View/Fit/FitSessionController.cpp index a212ae5877dec797c4e72f3e39996aa4caca5a5c..4ddead4e06d0157214d4c400e0ca70f53391782d 100644 --- a/GUI/View/Fit/FitSessionController.cpp +++ b/GUI/View/Fit/FitSessionController.cpp @@ -18,7 +18,6 @@ #include "GUI/Model/Job/FitParameterContainerItem.h" #include "GUI/Model/Job/FitSuiteItem.h" #include "GUI/Model/Job/JobItem.h" -#include "GUI/Support/Util/Error.h" #include "GUI/View/Fit/FitLog.h" #include "GUI/View/Fit/FitObjectiveBuilder.h" #include "GUI/View/Fit/FitWorkerLauncher.h" @@ -53,7 +52,7 @@ FitSessionController::~FitSessionController() = default; void FitSessionController::setJobItem(JobItem* jobItem) { if (m_jobItem && m_jobItem != jobItem) - throw Error("FitSuiteManager::setJobItem -> JobItem was already set."); + throw std::runtime_error("FitSuiteManager::setJobItem -> JobItem was already set."); m_jobItem = jobItem; ASSERT(m_jobItem); diff --git a/GUI/View/Fit/FitSessionManager.cpp b/GUI/View/Fit/FitSessionManager.cpp index 2a418104fbbe9a0a5d752337ea2575644a56ce49..646e062012396ec9af63b1a1bb46df3c66ea46b8 100644 --- a/GUI/View/Fit/FitSessionManager.cpp +++ b/GUI/View/Fit/FitSessionManager.cpp @@ -14,7 +14,6 @@ #include "GUI/View/Fit/FitSessionManager.h" #include "GUI/Model/Job/JobItem.h" -#include "GUI/Support/Util/Error.h" #include "GUI/View/Fit/FitSessionController.h" FitSessionManager::FitSessionManager(QObject* parent) @@ -61,8 +60,8 @@ void FitSessionManager::removeController(JobItem* jobItem) { auto it = m_item_to_controller.find(jobItem); if (it == m_item_to_controller.end()) - throw Error("FitActivityManager::removeFitSession -> Error. " - "Cannot find fit session"); + throw std::runtime_error("FitActivityManager::removeFitSession -> Error. " + "Cannot find fit session"); if (m_activeController == it.value()) m_activeController = nullptr; diff --git a/GUI/View/Fit/ParameterTuningWidget.cpp b/GUI/View/Fit/ParameterTuningWidget.cpp index e6aa671c624f7534c0fb66c80de646adf21115da..05bca1dc6c3b5203e4f00af1610957181098f91d 100644 --- a/GUI/View/Fit/ParameterTuningWidget.cpp +++ b/GUI/View/Fit/ParameterTuningWidget.cpp @@ -18,7 +18,6 @@ #include "GUI/Model/Job/ParameterTreeItems.h" #include "GUI/Model/Model/ParameterTuningModel.h" #include "GUI/Model/Project/ProjectDocument.h" -#include "GUI/Support/Util/Error.h" #include "GUI/View/Fit/ParameterTuningDelegate.h" #include "GUI/View/Fit/SliderSettingsWidget.h" #include "GUI/View/Info/CautionSign.h" @@ -140,8 +139,8 @@ void ParameterTuningWidget::updateParameterModel() return; if (!jobItem()->sampleItem() || !jobItem()->instrumentItem()) - throw Error("ModelTuningWidget::updateParameterModel -> Error." - "JobItem doesn't have sample or instrument model."); + throw std::runtime_error("ModelTuningWidget::updateParameterModel -> Error." + "JobItem doesn't have sample or instrument model."); delete m_parameterTuningModel; m_parameterTuningModel = diff --git a/GUI/View/Import/RealDataPresenter.cpp b/GUI/View/Import/RealDataPresenter.cpp index 247eaec964eb45f322d01fbfbf8371f4652d0bbd..6a32a875fb920896db41c9fecf7721088733d0b8 100644 --- a/GUI/View/Import/RealDataPresenter.cpp +++ b/GUI/View/Import/RealDataPresenter.cpp @@ -14,7 +14,6 @@ #include "GUI/View/Import/RealDataPresenter.h" #include "Base/Util/Assert.h" -#include "GUI/Support/Util/Error.h" #include "GUI/View/Import/RealDataMaskWidget.h" #include "GUI/View/Import/SpecularDataImportWidget.h" #include "GUI/View/Plot2D/IntensityDataWidget.h" @@ -63,6 +62,7 @@ QStringList RealDataPresenter::activePresentationList() const result << "Reflectometry (Configuration)"; result << "Reflectometry (Graph only)"; } else - throw Error("Error in RealDataPresenter::activePresentationList: unsupported data type"); + throw std::runtime_error( + "Error in RealDataPresenter::activePresentationList: unsupported data type"); return result; } diff --git a/GUI/View/Import/RealDataSelectorWidget.cpp b/GUI/View/Import/RealDataSelectorWidget.cpp index 7f0fc8dda08237459f699765f7eeb21b27743810..452693247f9cc2dd203aa5a3ddcbc0143544be28 100644 --- a/GUI/View/Import/RealDataSelectorWidget.cpp +++ b/GUI/View/Import/RealDataSelectorWidget.cpp @@ -19,7 +19,6 @@ #include "GUI/Model/Model/RealTreeModel.h" #include "GUI/Support/IO/AbstractDataLoader1D.h" #include "GUI/Support/IO/DataLoaders1D.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/Util/StyleUtil.h" #include "GUI/View/Import/ImportDataUtil.h" #include "GUI/View/Import/RealDataPropertiesWidget.h" @@ -319,7 +318,8 @@ void RealDataSelectorWidget::importData2D() try { if (data->rank() != 2) - throw Error("The content could not be interpreted correctly as 2-dimensional."); + throw std::runtime_error( + "The content could not be interpreted correctly as 2-dimensional."); realItem->setDatafield(data.release()); setCurrentItem(realItem); diff --git a/GUI/View/Mask/MaskGraphicsScene.cpp b/GUI/View/Mask/MaskGraphicsScene.cpp index dd0b292243ad5ff7e7344a1f25f0763a45237fd6..242e55d6cdb4600c9e49f1c36df1854e0a2f9c46 100644 --- a/GUI/View/Mask/MaskGraphicsScene.cpp +++ b/GUI/View/Mask/MaskGraphicsScene.cpp @@ -17,7 +17,6 @@ #include "GUI/Model/Data/MaskItems.h" #include "GUI/Model/Data/ProjectionItems.h" #include "GUI/Model/Project/ProjectDocument.h" -#include "GUI/Support/Util/Error.h" #include "GUI/View/Mask/ColorMapSceneAdaptor.h" #include "GUI/View/Mask/MaskGraphicsProxy.h" #include "GUI/View/Mask/MaskViewFactory.h" diff --git a/GUI/View/Mask/MaskViewFactory.cpp b/GUI/View/Mask/MaskViewFactory.cpp index 6657951be8c374fad6af923de12576cc206fe913..4270775f4980ebe1a149c3511184e278f8887a5d 100644 --- a/GUI/View/Mask/MaskViewFactory.cpp +++ b/GUI/View/Mask/MaskViewFactory.cpp @@ -15,7 +15,6 @@ #include "GUI/View/Mask/MaskViewFactory.h" #include "GUI/Model/Data/MaskItems.h" #include "GUI/Model/Data/ProjectionItems.h" -#include "GUI/Support/Util/Error.h" #include "GUI/View/Mask/EllipseView.h" #include "GUI/View/Mask/LineViews.h" #include "GUI/View/Mask/MaskAllView.h" diff --git a/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp b/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp index 3c1bfb60f7ec5ee40977bbc7a3a625e9c983e023..e82f4f14157dcc5c5820e896ec05cf2502dc15dd 100644 --- a/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp +++ b/GUI/View/Plot2D/IntensityDataFFTPresenter.cpp @@ -17,7 +17,6 @@ #include "Device/Data/DataUtil.h" #include "Device/Data/Datafield.h" #include "GUI/Model/Data/IntensityDataItem.h" -#include "GUI/Support/Util/Error.h" #include <QApplication> IntensityDataFFTPresenter::IntensityDataFFTPresenter(QWidget* parent) diff --git a/GUI/View/PlotUtil/RangeUtil.cpp b/GUI/View/PlotUtil/RangeUtil.cpp index 5aea451976124dc4a12379977495b9c1b26d92e3..14bfcc306cd8db25bef7c3e1a5f524bad85f415e 100644 --- a/GUI/View/PlotUtil/RangeUtil.cpp +++ b/GUI/View/PlotUtil/RangeUtil.cpp @@ -16,7 +16,6 @@ #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Data/IntensityDataItem.h" #include "GUI/Model/Data/SpecularDataItem.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/Util/StyleUtil.h" #include <qcustomplot.h> diff --git a/GUI/View/Project/ProjectManager.cpp b/GUI/View/Project/ProjectManager.cpp index c9a8461db3602151e30cfac36e811ea3522c702a..8b2a95ffa0a1e8984d748b5672178694ad9466e6 100644 --- a/GUI/View/Project/ProjectManager.cpp +++ b/GUI/View/Project/ProjectManager.cpp @@ -16,7 +16,6 @@ #include "Base/Util/Assert.h" #include "GUI/Application/ApplicationSettings.h" #include "GUI/Support/IO/ProjectUtil.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/Util/MessageService.h" #include "GUI/View/Info/MessageBox.h" #include "GUI/View/Info/ProjectLoadProblemDialog.h" @@ -49,8 +48,8 @@ ProjectManager::ProjectManager(QObject* parent) : QObject(parent) { if (s_instance != nullptr) - throw Error("ProjectManager::ProjectManager -> Error. Attempt to create " - "ProjectManager twice."); + throw std::runtime_error("ProjectManager::ProjectManager -> Error. Attempt to create " + "ProjectManager twice."); s_instance = this; } @@ -64,8 +63,8 @@ ProjectManager::~ProjectManager() ProjectManager* ProjectManager::instance() { if (!s_instance) - throw Error("ProjectManager::instance -> Error. Attempt to access " - "non existing ProjectManager."); + throw std::runtime_error("ProjectManager::instance -> Error. Attempt to access " + "non existing ProjectManager."); return s_instance; } @@ -338,7 +337,7 @@ void ProjectManager::openProject(QString projectPullPath) void ProjectManager::createNewProject() { if (gProjectDocument.has_value()) - throw Error("ProjectManager::createNewProject -> Project already exists"); + throw std::runtime_error("ProjectManager::createNewProject -> Project already exists"); gProjectDocument = new ProjectDocument(); diff --git a/GUI/View/Projection/SaveProjectionsAssistant.cpp b/GUI/View/Projection/SaveProjectionsAssistant.cpp index bb358ff627a686ee529609498ca8c1bdf3cfcb0a..6107dc083905b86237f7f1a6e91fbb3f742cdd3b 100644 --- a/GUI/View/Projection/SaveProjectionsAssistant.cpp +++ b/GUI/View/Projection/SaveProjectionsAssistant.cpp @@ -20,7 +20,6 @@ #include "GUI/Model/Data/IntensityDataItem.h" #include "GUI/Model/Data/MaskItems.h" #include "GUI/Model/Project/ProjectDocument.h" -#include "GUI/Support/Util/Error.h" #include <QFileDialog> #include <QTextStream> #include <boost/polymorphic_cast.hpp> @@ -79,8 +78,8 @@ void SaveProjectionsAssistant::saveProjections(QWidget* parent, IntensityDataIte QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - throw Error("TestGUI::Project::Util::createTestFile -> Error. " - "Cannot create file"); + throw std::runtime_error("TestGUI::Project::Util::createTestFile -> Error. " + "Cannot create file"); m_field = intensityItem->c_field(); diff --git a/Tests/Unit/GUI/TestJobModel.cpp b/Tests/Unit/GUI/TestJobModel.cpp index 2e5d197e51b5dbbb43406285b6810ab55a019a14..a211c79d6e7f43df5e99cca58193da73fa377789 100644 --- a/Tests/Unit/GUI/TestJobModel.cpp +++ b/Tests/Unit/GUI/TestJobModel.cpp @@ -5,7 +5,6 @@ #include "GUI/Model/Device/RealItem.h" #include "GUI/Model/Job/JobItem.h" #include "GUI/Model/Model/JobModel.h" -#include "GUI/Support/Util/Error.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/Unit/GUI/Utils.h" #include <QTest> @@ -42,7 +41,7 @@ TEST(TestJobModel, nonXMLData) // replacing the data inside RealItem with the data of different dimensions auto data = UTest::GUI::createData(3.0, UTest::GUI::DIM::D2); - EXPECT_THROW(dynamic_cast<RealItem*>(realItem)->setDatafield(data.get()), Error); + EXPECT_THROW(dynamic_cast<RealItem*>(realItem)->setDatafield(data.get()), std::runtime_error); EXPECT_EQ(jobModel.dataItems().size(), 2); } diff --git a/Tests/Unit/GUI/TestProjectDocument.cpp b/Tests/Unit/GUI/TestProjectDocument.cpp index e6c96f108dbbbbc896a34d7f92d78dbdd6438414..9feeced63bde860808310e96eec918105636c06b 100644 --- a/Tests/Unit/GUI/TestProjectDocument.cpp +++ b/Tests/Unit/GUI/TestProjectDocument.cpp @@ -7,7 +7,6 @@ #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Support/IO/AbstractDataLoader.h" #include "GUI/Support/IO/ProjectUtil.h" -#include "GUI/Support/Util/Error.h" #include "GUI/Support/Util/Path.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/Unit/GUI/Utils.h" @@ -117,7 +116,7 @@ TEST_F(TestProjectDocument, failingProjectSave) QSignalSpy spyDocument(document.get(), SIGNAL(modifiedStateChanged())); - EXPECT_THROW(document->saveProjectFileWithData(projectFileName), Error); + EXPECT_THROW(document->saveProjectFileWithData(projectFileName), std::runtime_error); EXPECT_EQ(spyDocument.count(), 0); EXPECT_FALSE(QFile::exists(projectFileName)); diff --git a/Tests/Unit/GUI/TestProjectUtils.cpp b/Tests/Unit/GUI/TestProjectUtils.cpp index 62b75aaacbfb80c47ddd028cd212d18d59cccf2f..7ababebecb11f12a7c8459efaccfeb26b8de92ba 100644 --- a/Tests/Unit/GUI/TestProjectUtils.cpp +++ b/Tests/Unit/GUI/TestProjectUtils.cpp @@ -1,6 +1,5 @@ #include "GUI/Support/IO/ItemFileNameUtil.h" #include "GUI/Support/IO/ProjectUtil.h" -#include "GUI/Support/Util/Error.h" #include "Tests/GTestWrapper/google_test.h" #include "Utils.h" #include <QDir> @@ -15,9 +14,9 @@ QStringList nonXMLDataInDir(const QString& dirname) QDir dir(dirname); if (!dir.exists()) - throw Error("GUI::Project::Util::nonXMLDataInDir -> Error. Non existing " - "directory '" - + dirname + "'."); + throw std::runtime_error("GUI::Project::Util::nonXMLDataInDir -> Error. Non existing " + "directory '" + + dirname.toLatin1() + "'."); return dir.entryList(GUI::Model::FilenameUtil::nonXMLFileNameFilters()); } @@ -33,8 +32,8 @@ protected: QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - throw Error("TestGUI::Project::Util::createTestFile -> Error. " - "Cannot create file"); + throw std::runtime_error("TestGUI::Project::Util::createTestFile -> Error. " + "Cannot create file"); QTextStream out(&file); out << "Test file " << 42 << "\n"; diff --git a/Tests/Unit/GUI/Utils.cpp b/Tests/Unit/GUI/Utils.cpp index 931d2f90f95014415adc43c6d84d33f6ed6b3028..e3ea9571bfa509fa63b441df0b0418d0cbc8403f 100644 --- a/Tests/Unit/GUI/Utils.cpp +++ b/Tests/Unit/GUI/Utils.cpp @@ -35,8 +35,8 @@ void UTest::GUI::create_dir(const QString& dir_name) QDir(dir_name).removeRecursively(); if (!QDir(".").mkdir(dir_name)) - throw Error("UTest::GUI::create_dir -> Error. Cannot create '" + dir_name - + "' in parent directory '.'."); + throw std::runtime_error("UTest::GUI::create_dir -> Error. Cannot create '" + + dir_name.toLatin1() + "' in parent directory '.'."); } std::unique_ptr<Datafield> UTest::GUI::createData(double value, DIM n_dim) diff --git a/Tests/Unit/GUI/Utils.h b/Tests/Unit/GUI/Utils.h index c7e3bece9e3adccb9eeb8dab073becea6282cb8f..de8c743f866651c872de8f868665d739bdbe2e6c 100644 --- a/Tests/Unit/GUI/Utils.h +++ b/Tests/Unit/GUI/Utils.h @@ -15,7 +15,6 @@ #ifndef BORNAGAIN_TESTS_UNIT_GUI_UTILS_H #define BORNAGAIN_TESTS_UNIT_GUI_UTILS_H -#include "GUI/Support/Util/Error.h" #include "GUI/Support/XML/UtilXML.h" #include <QDir> @@ -74,8 +73,9 @@ void readXMLFile(QString path, T& model, QString tag) r.readNextStartElement(); if (r.name().toString() != tag) - throw Error("UTest::GUI::readXMLFile -> Error. The found tag '" + r.name().toString() - + "' differs from '" + tag + "' in file '" + path + "'"); + throw std::runtime_error("UTest::GUI::readXMLFile -> Error. The found tag '" + + r.name().toString().toLatin1() + "' differs from '" + + tag.toLatin1() + "' in file '" + path.toLatin1() + "'"); model.readFrom(&r); XML::gotoEndElementOfTag(&r, r.name().toString());