From a59f25c5be4b98338d98f0395edff655d24a9f36 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Wed, 25 Nov 2020 09:15:29 +0100 Subject: [PATCH] prefer std::runtime_error over Exceptions of our own --- Base/Axis/ConstKBinAxis.cpp | 5 +- Base/Axis/CustomBinAxis.cpp | 11 +-- Base/Axis/FixedBinAxis.cpp | 9 +- Base/Axis/IAxis.cpp | 8 +- Base/Axis/VariableBinAxis.cpp | 25 +++-- Base/Types/Exceptions.cpp | 70 -------------- Base/Types/Exceptions.h | 92 ------------------- Base/Utils/FileSystemUtils.cpp | 1 - .../Computation/ParticleLayoutComputation.cpp | 1 - Core/Export/SampleLabelHandler.cpp | 3 +- Core/Export/SampleLabelHandler.h | 1 - Core/Export/SampleToPython.cpp | 2 +- Core/Export/SimulationToPython.cpp | 23 ++--- Core/Simulation/GISASSimulation.cpp | 7 +- Core/Simulation/ISimulation.cpp | 17 ++-- Core/Simulation/OffSpecSimulation.cpp | 12 +-- Device/Beam/Beam.cpp | 7 +- Device/Data/LLData.h | 9 +- Device/Data/OutputData.cpp | 2 +- Device/Data/OutputData.h | 42 ++++----- Device/Detector/DetectionProperties.cpp | 5 +- Device/Detector/DetectorMask.cpp | 4 +- Device/Detector/IDetector.cpp | 9 +- Device/Detector/IsGISAXSDetector.cpp | 5 +- Device/Detector/RectangularDetector.cpp | 7 +- Device/Detector/RegionOfInterest.cpp | 8 +- Device/Detector/SimulationAreaIterator.cpp | 4 +- Device/Detector/SphericalDetector.cpp | 2 +- Device/Histo/Histogram2D.cpp | 2 +- Device/Histo/Histogram2D.h | 4 +- Device/Histo/IHistogram.cpp | 18 ++-- Device/InputOutput/DataFormatUtils.cpp | 27 +++--- Device/InputOutput/OutputDataReadFactory.cpp | 1 - Device/InputOutput/OutputDataReader.cpp | 11 +-- Device/InputOutput/OutputDataWriteFactory.cpp | 1 - Device/InputOutput/OutputDataWriter.cpp | 14 +-- Device/InputOutput/TiffHandler.cpp | 28 +++--- Device/Instrument/FourierTransform.cpp | 9 +- Device/Instrument/Instrument.cpp | 2 +- Device/Instrument/IntensityDataFunctions.cpp | 25 +++-- Device/Intensity/ArrayUtils.cpp | 2 +- Device/Mask/Ellipse.cpp | 3 +- Device/Mask/Polygon.cpp | 5 +- Device/Mask/Rectangle.cpp | 5 +- .../ConvolutionDetectorResolution.cpp | 22 ++--- Device/Resolution/Convolve.cpp | 17 ++-- .../CsvImportAssistant/CsvImportAssistant.cpp | 3 +- .../RealSpaceBuilderUtils.cpp | 5 +- .../RealSpaceMesoCrystalUtils.cpp | 25 +++-- Param/Base/IParameterized.cpp | 1 - Param/Base/ParameterPool.cpp | 26 +++--- Param/Distrib/DistributionHandler.cpp | 9 +- Param/Distrib/Distributions.cpp | 35 ++++--- Param/Distrib/ParameterDistribution.cpp | 26 ++---- Param/Node/NodeUtils.cpp | 5 +- .../InterferenceFunction1DLattice.cpp | 1 - .../InterferenceFunction2DLattice.cpp | 15 ++- .../InterferenceFunction2DParaCrystal.cpp | 15 ++- .../InterferenceFunction2DSuperLattice.cpp | 1 - .../InterferenceFunctionFinite2DLattice.cpp | 1 - .../InterferenceFunctionFinite3DLattice.cpp | 1 - .../InterferenceFunctionRadialParaCrystal.cpp | 7 +- Sample/Aggregate/ParticleLayout.cpp | 1 - Sample/Correlations/FTDistributions1D.cpp | 3 +- Sample/Correlations/FTDistributions2D.cpp | 3 +- Sample/Fresnel/FormFactorCoherentSum.cpp | 5 +- .../HardParticle/FormFactorAnisoPyramid.cpp | 5 +- .../FormFactorCantellatedCube.cpp | 3 +- Sample/HardParticle/FormFactorCone.cpp | 5 +- Sample/HardParticle/FormFactorCone6.cpp | 5 +- .../HardParticle/FormFactorCuboctahedron.cpp | 5 +- .../HardParticle/FormFactorHollowSphere.cpp | 6 +- Sample/HardParticle/FormFactorPyramid.cpp | 5 +- Sample/HardParticle/FormFactorTetrahedron.cpp | 5 +- .../HardParticle/FormFactorTruncatedCube.cpp | 3 +- .../FormFactorTruncatedSphere.cpp | 3 +- .../FormFactorTruncatedSpheroid.cpp | 3 +- .../DecouplingApproximationStrategy.cpp | 8 +- .../IInterferenceFunctionStrategy.cpp | 1 - .../Interference/SSCApproximationStrategy.cpp | 1 - Sample/Material/Material.cpp | 7 +- Sample/Multilayer/Layer.cpp | 3 +- Sample/Multilayer/MultiLayer.cpp | 7 +- Sample/Particle/FormFactorCrystal.cpp | 1 - Sample/Particle/ParticleComposition.cpp | 3 +- Sample/Particle/ParticleDistribution.cpp | 1 - Sample/RT/ILayerRTCoefficients.h | 15 ++- Sample/Scattering/IBornFF.cpp | 1 - Sample/Scattering/ISample.cpp | 1 - Sample/Slice/LayerInterface.cpp | 7 +- .../UnitTests/Core/Axes/FixedBinAxisTest.cpp | 9 +- Tests/UnitTests/Core/Axes/Histogram1DTest.cpp | 2 +- .../Core/Axes/VariableBinAxisTest.cpp | 15 ++- .../Core/DataStructure/LLDataTest.cpp | 8 +- .../Core/Detector/RectangularDetectorTest.cpp | 2 +- .../Core/Detector/RegionOfInterestTest.cpp | 4 +- .../Core/Detector/SphericalDetectorTest.cpp | 2 +- Tests/UnitTests/Core/Other/MaterialTest.cpp | 1 - .../Core/Parameters/DistributionsTest.cpp | 3 +- .../Parameters/ParameterDistributionTest.cpp | 6 +- .../Core/Parameters/ParameterPoolTest.cpp | 13 +-- .../Core/Sample/FormFactorCoherentSumTest.cpp | 3 +- Tests/UnitTests/Core/Sample/INodeTest.cpp | 3 +- auto/Wrap/doxygenDevice.i | 33 +++---- auto/Wrap/libBornAgainDevice.py | 10 +- auto/Wrap/libBornAgainDevice_wrap.cpp | 4 +- 106 files changed, 354 insertions(+), 643 deletions(-) delete mode 100644 Base/Types/Exceptions.cpp delete mode 100644 Base/Types/Exceptions.h diff --git a/Base/Axis/ConstKBinAxis.cpp b/Base/Axis/ConstKBinAxis.cpp index 546bdb3e4c0..ac2b29179c9 100644 --- a/Base/Axis/ConstKBinAxis.cpp +++ b/Base/Axis/ConstKBinAxis.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Base/Axis/ConstKBinAxis.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Algorithms.h" #include <iomanip> @@ -23,7 +22,7 @@ ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins) ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins, double start, double end) : VariableBinAxis(name, nbins), m_start(start), m_end(end) { if (m_start >= m_end) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "ConstKBinAxis::ConstKBinAxis() -> Error. start >= end is not allowed."); double start_sin = std::sin(m_start); @@ -44,7 +43,7 @@ ConstKBinAxis* ConstKBinAxis::clone() const { ConstKBinAxis* ConstKBinAxis::createClippedAxis(double left, double right) const { if (left >= right) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "ConstKBinAxis::createClippedAxis() -> Error. 'left'' should be smaller than 'right'"); if (left < lowerBound()) diff --git a/Base/Axis/CustomBinAxis.cpp b/Base/Axis/CustomBinAxis.cpp index 4812cfaef63..4a65292dfa0 100644 --- a/Base/Axis/CustomBinAxis.cpp +++ b/Base/Axis/CustomBinAxis.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Base/Axis/CustomBinAxis.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Algorithms.h" #include <iomanip> #include <limits> @@ -21,8 +20,8 @@ CustomBinAxis::CustomBinAxis(const std::string& name, size_t nbins, double start, double end) : VariableBinAxis(name, nbins), m_start(start), m_end(end) { if (m_start >= m_end) - throw Exceptions::LogicErrorException("CustomBinAxis::CustomBinAxis() -> Error." - " start >= end is not allowed."); + throw std::runtime_error("CustomBinAxis::CustomBinAxis() -> Error." + " start >= end is not allowed."); double start_sin = std::sin(start); double end_sin = std::sin(end); @@ -47,7 +46,7 @@ CustomBinAxis* CustomBinAxis::clone() const { Bin1D CustomBinAxis::bin(size_t index) const { if (index >= m_nbins) - throw Exceptions::OutOfBoundsException("CustomBinAxis::bin() -> Error. Wrong index."); + throw std::runtime_error("CustomBinAxis::bin() -> Error. Wrong index."); Bin1D result(m_bin_centers[index], m_bin_centers[index]); return result; @@ -58,8 +57,8 @@ std::vector<double> CustomBinAxis::binCenters() const { } CustomBinAxis* CustomBinAxis::createClippedAxis(double /* left */, double /* right */) const { - throw Exceptions::NotImplementedException("VariableBinAxis::CustomBinAxis() -> Error." - " Not implemented."); + throw std::runtime_error("VariableBinAxis::CustomBinAxis() -> Error." + " Not implemented."); } void CustomBinAxis::print(std::ostream& ostr) const { diff --git a/Base/Axis/FixedBinAxis.cpp b/Base/Axis/FixedBinAxis.cpp index 9a25c492220..aa6f874cff4 100644 --- a/Base/Axis/FixedBinAxis.cpp +++ b/Base/Axis/FixedBinAxis.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Base/Axis/FixedBinAxis.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Algorithms.h" #include "Base/Utils/PyFmt.h" #include <iomanip> @@ -29,7 +28,7 @@ FixedBinAxis* FixedBinAxis::clone() const { double FixedBinAxis::operator[](size_t index) const { if (index >= m_nbins) - throw Exceptions::OutOfBoundsException("FixedBinAxis::operator[] -> Error. Wrong index."); + throw std::runtime_error("FixedBinAxis::operator[] -> Error. Wrong index."); double step = (m_end - m_start) / m_nbins; return m_start + (index + 0.5) * step; @@ -37,7 +36,7 @@ double FixedBinAxis::operator[](size_t index) const { Bin1D FixedBinAxis::bin(size_t index) const { if (index >= m_nbins) - throw Exceptions::OutOfBoundsException("FixedBinAxis::bin() -> Error. Wrong index."); + throw std::runtime_error("FixedBinAxis::bin() -> Error. Wrong index."); double step = (m_end - m_start) / m_nbins; Bin1D result(m_start + step * index, m_start + step * (index + 1)); @@ -76,8 +75,8 @@ std::vector<double> FixedBinAxis::binBoundaries() const { FixedBinAxis* FixedBinAxis::createClippedAxis(double left, double right) const { if (left >= right) - throw Exceptions::LogicErrorException("FixedBinAxis::createClippedAxis() -> Error. " - "'left' should be smaller than 'right'"); + throw std::runtime_error("FixedBinAxis::createClippedAxis() -> Error. " + "'left' should be smaller than 'right'"); if (left < lowerBound()) left = bin(0).center(); diff --git a/Base/Axis/IAxis.cpp b/Base/Axis/IAxis.cpp index 0a508d3f9b1..5b56e268500 100644 --- a/Base/Axis/IAxis.cpp +++ b/Base/Axis/IAxis.cpp @@ -13,23 +13,21 @@ // ************************************************************************************************ #include "Base/Axis/IAxis.h" -#include "Base/Types/Exceptions.h" bool IAxis::equals(const IAxis& other) const { return getName() == other.getName(); } std::vector<double> IAxis::binCenters() const { - throw Exceptions::NotImplementedException("IAxis::binCenters() -> Error. Not implemented."); + throw std::runtime_error("IAxis::binCenters() -> Error. Not implemented."); } std::vector<double> IAxis::binBoundaries() const { - throw Exceptions::NotImplementedException("IAxis::binBoundaries() -> Error. Not implemented."); + throw std::runtime_error("IAxis::binBoundaries() -> Error. Not implemented."); } IAxis* IAxis::createClippedAxis(double /* left */, double /* right */) const { - throw Exceptions::NotImplementedException( - "IAxis::createClippedAxis() -> Error. Not implemented."); + throw std::runtime_error("IAxis::createClippedAxis() -> Error. Not implemented."); } bool IAxis::contains(double value) const { diff --git a/Base/Axis/VariableBinAxis.cpp b/Base/Axis/VariableBinAxis.cpp index cef438eb988..6662d1c4ec9 100644 --- a/Base/Axis/VariableBinAxis.cpp +++ b/Base/Axis/VariableBinAxis.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Base/Axis/VariableBinAxis.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Algorithms.h" #include <algorithm> #include <iomanip> @@ -22,9 +21,8 @@ VariableBinAxis::VariableBinAxis(const std::string& name, size_t nbins, const std::vector<double>& bin_boundaries) : IAxis(name), m_nbins(nbins) { if (m_nbins != bin_boundaries.size() - 1) - throw Exceptions::LogicErrorException( - "VariableBinAxis::VariableBinAxis() -> Error! " - "The size of bin_boundaries should be of size [nbins+1]."); + throw std::runtime_error("VariableBinAxis::VariableBinAxis() -> Error! " + "The size of bin_boundaries should be of size [nbins+1]."); setBinBoundaries(bin_boundaries); } @@ -43,7 +41,7 @@ double VariableBinAxis::operator[](size_t index) const { Bin1D VariableBinAxis::bin(size_t index) const { if (index >= m_nbins) - throw Exceptions::OutOfBoundsException("VariableBinAxis::bin() -> Error. Wrong index."); + throw std::runtime_error("VariableBinAxis::bin() -> Error. Wrong index."); Bin1D result(m_bin_boundaries[index], m_bin_boundaries[index + 1]); return result; @@ -63,9 +61,8 @@ double VariableBinAxis::binCenter(size_t index) const { size_t VariableBinAxis::findClosestIndex(double value) const { if (m_bin_boundaries.size() < 2) - throw Exceptions::ClassInitializationException( - "VariableBinAxis::findClosestIndex() -> Error! " - "VariableBinAxis not correctly initialized"); + throw std::runtime_error("VariableBinAxis::findClosestIndex() -> Error! " + "VariableBinAxis not correctly initialized"); if (value < lowerBound()) { return 0; } else if (value >= upperBound()) { @@ -92,8 +89,8 @@ std::vector<double> VariableBinAxis::binCenters() const { VariableBinAxis* VariableBinAxis::createClippedAxis(double left, double right) const { if (left >= right) - throw Exceptions::LogicErrorException("VariableBinAxis::createClippedAxis() -> Error. " - "'left'' should be smaller than 'right'"); + throw std::runtime_error("VariableBinAxis::createClippedAxis() -> Error. " + "'left'' should be smaller than 'right'"); if (left < lowerBound()) left = bin(0).center(); @@ -148,16 +145,16 @@ void VariableBinAxis::setBinBoundaries(const std::vector<double>& bin_boundaries std::sort(vec_sorted.begin(), vec_sorted.end()); for (size_t i = 0; i < bin_boundaries.size(); ++i) { if (vec_sorted[i] != bin_boundaries[i]) - throw Exceptions::LogicErrorException("VariableBinAxis::VariableBinAxis() -> Error. " - "Array with bin edges is not sorted."); + throw std::runtime_error("VariableBinAxis::VariableBinAxis() -> Error. " + "Array with bin edges is not sorted."); } std::vector<double> vec = bin_boundaries; vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); if (vec.size() != bin_boundaries.size()) - throw Exceptions::LogicErrorException("VariableBinAxis::VariableBinAxis() -> Error. " - "Array with bin edges contains repeating values."); + throw std::runtime_error("VariableBinAxis::VariableBinAxis() -> Error. " + "Array with bin edges contains repeating values."); m_bin_boundaries = bin_boundaries; } diff --git a/Base/Types/Exceptions.cpp b/Base/Types/Exceptions.cpp deleted file mode 100644 index e8f0339e8ce..00000000000 --- a/Base/Types/Exceptions.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Base/Types/Exceptions.cpp -//! @brief Implements class Exceptions. -//! -//! @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 "Base/Types/Exceptions.h" -#include <iostream> - -namespace Exceptions { - -void LogExceptionMessage(const std::string&) { - // std::cerr << message << std::endl; -} - -NotImplementedException::NotImplementedException(const std::string& message) - : std::logic_error(message) { - LogExceptionMessage(message); -} - -NullPointerException::NullPointerException(const std::string& message) : std::logic_error(message) { - LogExceptionMessage(message); -} - -OutOfBoundsException::OutOfBoundsException(const std::string& message) : std::logic_error(message) { - LogExceptionMessage(message); -} - -ClassInitializationException::ClassInitializationException(const std::string& message) - : std::runtime_error(message) { - LogExceptionMessage(message); -} - -LogicErrorException::LogicErrorException(const std::string& message) : std::logic_error(message) { - LogExceptionMessage(message); -} - -RuntimeErrorException::RuntimeErrorException(const std::string& message) - : std::runtime_error(message) { - LogExceptionMessage(message); -} - -DomainErrorException::DomainErrorException(const std::string& message) - : std::domain_error(message) { - LogExceptionMessage(message); -} - -FileNotIsOpenException::FileNotIsOpenException(const std::string& message) - : std::runtime_error(message) { - LogExceptionMessage(message); -} - -FileIsBadException::FileIsBadException(const std::string& message) : std::runtime_error(message) { - LogExceptionMessage(message); -} - -FormatErrorException::FormatErrorException(const std::string& message) - : std::runtime_error(message) { - LogExceptionMessage(message); -} - -} // namespace Exceptions diff --git a/Base/Types/Exceptions.h b/Base/Types/Exceptions.h deleted file mode 100644 index 2ed8ba76129..00000000000 --- a/Base/Types/Exceptions.h +++ /dev/null @@ -1,92 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Base/Types/Exceptions.h -//! @brief Defines many exception classes in namespace Exceptionss. -//! -//! @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_BASE_TYPES_EXCEPTIONS_H -#define BORNAGAIN_BASE_TYPES_EXCEPTIONS_H - -#include <stdexcept> -#include <string> - -#ifdef _WIN32 -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4275) -#endif -#endif - -//! Different exceptions, all inheriting from std::exception. - -namespace Exceptions { - -class NotImplementedException : public std::logic_error { -public: - NotImplementedException(const std::string& message); -}; - -class NullPointerException : public std::logic_error { -public: - NullPointerException(const std::string& message); -}; - -class OutOfBoundsException : public std::logic_error { -public: - OutOfBoundsException(const std::string& message); -}; - -class ClassInitializationException : public std::runtime_error { -public: - ClassInitializationException(const std::string& message); -}; - -class LogicErrorException : public std::logic_error { -public: - LogicErrorException(const std::string& message); -}; - -class RuntimeErrorException : public std::runtime_error { -public: - RuntimeErrorException(const std::string& message); -}; - -class DomainErrorException : public std::domain_error { -public: - DomainErrorException(const std::string& message); -}; - -class FileNotIsOpenException : public std::runtime_error { -public: - FileNotIsOpenException(const std::string& message); -}; - -class FileIsBadException : public std::runtime_error { -public: - FileIsBadException(const std::string& message); -}; - -class FormatErrorException : public std::runtime_error { -public: - FormatErrorException(const std::string& message); -}; - -void LogExceptionMessage(const std::string& message); - -} // namespace Exceptions - -#ifdef _WIN32 -#ifdef _MSC_VER -#pragma warning(pop) -#endif -#endif - -#endif // BORNAGAIN_BASE_TYPES_EXCEPTIONS_H diff --git a/Base/Utils/FileSystemUtils.cpp b/Base/Utils/FileSystemUtils.cpp index 8a330c9e52d..3b5d60bd866 100644 --- a/Base/Utils/FileSystemUtils.cpp +++ b/Base/Utils/FileSystemUtils.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Base/Utils/FileSystemUtils.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Assert.h" #include <boost/filesystem.hpp> #include <codecvt> diff --git a/Core/Computation/ParticleLayoutComputation.cpp b/Core/Computation/ParticleLayoutComputation.cpp index 16359a569a1..3a3ff598659 100644 --- a/Core/Computation/ParticleLayoutComputation.cpp +++ b/Core/Computation/ParticleLayoutComputation.cpp @@ -14,7 +14,6 @@ #include "Core/Computation/ParticleLayoutComputation.h" #include "Base/Pixel/SimulationElement.h" -#include "Base/Types/Exceptions.h" #include "Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h" #include "Sample/Interference/DecouplingApproximationStrategy.h" #include "Sample/Interference/SSCApproximationStrategy.h" diff --git a/Core/Export/SampleLabelHandler.cpp b/Core/Export/SampleLabelHandler.cpp index 611990dcd9f..ce9b858d33b 100644 --- a/Core/Export/SampleLabelHandler.cpp +++ b/Core/Export/SampleLabelHandler.cpp @@ -70,8 +70,7 @@ std::string SampleLabelHandler::labelParticle(const IAbstractParticle* abspartic return m_ParticleCompositionLabel[lattice_basis]; if (const auto mesocrystal = dynamic_cast<const MesoCrystal*>(absparticle)) return m_MesoCrystalLabel[mesocrystal]; - throw Exceptions::NotImplementedException( - "SampleLabelHandler::getLabel: called for unknown IParticle type"); + throw std::runtime_error("SampleLabelHandler::getLabel: called for unknown IParticle type"); } std::string SampleLabelHandler::labelRotation(const IRotation* rot) { diff --git a/Core/Export/SampleLabelHandler.h b/Core/Export/SampleLabelHandler.h index 10c136a3dd3..9d9a0f5cec5 100644 --- a/Core/Export/SampleLabelHandler.h +++ b/Core/Export/SampleLabelHandler.h @@ -15,7 +15,6 @@ #ifndef BORNAGAIN_CORE_EXPORT_SAMPLELABELHANDLER_H #define BORNAGAIN_CORE_EXPORT_SAMPLELABELHANDLER_H -#include "Base/Types/Exceptions.h" #include "Core/Export/OrderedMap.h" class Crystal; diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp index ff4fda2b0ff..e934ea4d0a1 100644 --- a/Core/Export/SampleToPython.cpp +++ b/Core/Export/SampleToPython.cpp @@ -477,7 +477,7 @@ std::string SampleToPython::defineInterferenceFunctions() const { << pyfmt::printDouble(lattice_hd->density()) << ")\n"; } else - throw Exceptions::NotImplementedException( + throw std::runtime_error( "Bug: ExportToPython::defineInterferenceFunctions() called with unexpected " "IInterferenceFunction " + interference->getName()); diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index 8f00c7ad034..01d3e6d8509 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -44,8 +44,7 @@ std::function<std::string(double)> printFunc(const IDetector* detector) { return pyfmt::printDouble; if (detector->defaultAxesUnits() == Axes::Units::RADIANS) return pyfmt::printDegrees; - throw Exceptions::RuntimeErrorException( - "SimulationToPython::defineMasks() -> Error. Unknown detector units."); + throw std::runtime_error("SimulationToPython::defineMasks() -> Error. Unknown detector units."); } //! returns true if it is (0, -1, 0) vector @@ -65,8 +64,8 @@ const std::string defineSimulate = "def run_simulation():\n" std::string defineDetector(const ISimulation* simulation) { const IDetector* const detector = simulation->instrument().getDetector(); if (detector->dimension() != 2) - throw Exceptions::RuntimeErrorException("defineDetector: " - "detector must be two-dimensional for GISAS"); + throw std::runtime_error("defineDetector: " + "detector must be two-dimensional for GISAS"); std::ostringstream result; result << std::setprecision(12); @@ -117,13 +116,12 @@ std::string defineDetector(const ISimulation* simulation) { << pyfmt::printDouble(det->getDirectBeamU0()) << ", " << pyfmt::printDouble(det->getDirectBeamV0()) << ")\n"; } else - throw Exceptions::RuntimeErrorException( - "defineDetector() -> Error. Unknown alignment."); + throw std::runtime_error("defineDetector() -> Error. Unknown alignment."); result << indent() << "simulation.setDetector(detector)\n"; } else - throw Exceptions::RuntimeErrorException("defineDetector() -> Error. " - "Unknown detector"); + throw std::runtime_error("defineDetector() -> Error. " + "Unknown detector"); if (detector->regionOfInterest()) { result << indent() << "simulation.setRegionOfInterest(" << printFunc(detector)(detector->regionOfInterest()->getXlow()) << ", " @@ -148,12 +146,11 @@ std::string defineDetectorResolutionFunction(const ISimulation* simulation) { result << printFunc(detector)(resfunc->getSigmaX()) << ", "; result << printFunc(detector)(resfunc->getSigmaY()) << "))\n"; } else - throw Exceptions::RuntimeErrorException( - "defineDetectorResolutionFunction() -> Error. " - "Unknown detector resolution function"); + throw std::runtime_error("defineDetectorResolutionFunction() -> Error. " + "Unknown detector resolution function"); } else - throw Exceptions::RuntimeErrorException("defineDetectorResolutionFunction() -> Error. " - "Not a ConvolutionDetectorResolution function"); + throw std::runtime_error("defineDetectorResolutionFunction() -> Error. " + "Not a ConvolutionDetectorResolution function"); } return result.str(); } diff --git a/Core/Simulation/GISASSimulation.cpp b/Core/Simulation/GISASSimulation.cpp index f15db695882..c4f54d5ed3c 100644 --- a/Core/Simulation/GISASSimulation.cpp +++ b/Core/Simulation/GISASSimulation.cpp @@ -26,9 +26,8 @@ GISASSimulation::GISASSimulation() { void GISASSimulation::prepareSimulation() { if (instrument().getDetectorDimension() != 2) - throw Exceptions::LogicErrorException( - "GISASSimulation::prepareSimulation() " - "-> Error. The detector was not properly configured."); + throw std::runtime_error("GISASSimulation::prepareSimulation() " + "-> Error. The detector was not properly configured."); instrument().initDetector(); ISimulation2D::prepareSimulation(); } @@ -42,7 +41,7 @@ SimulationResult GISASSimulation::result() const { void GISASSimulation::setBeamParameters(double wavelength, double alpha_i, double phi_i) { if (wavelength <= 0.0) - throw Exceptions::ClassInitializationException( + throw std::runtime_error( "ISimulation::setBeamParameters() -> Error. Incoming wavelength <= 0."); instrument().setBeamParameters(wavelength, alpha_i, phi_i); } diff --git a/Core/Simulation/ISimulation.cpp b/Core/Simulation/ISimulation.cpp index 0e39995d59b..f3b1c5021b8 100644 --- a/Core/Simulation/ISimulation.cpp +++ b/Core/Simulation/ISimulation.cpp @@ -72,10 +72,10 @@ void runComputations(std::vector<std::unique_ptr<IComputation>>& computations) { if (computation->isCompleted()) return; std::string message = computation->errorMessage(); - throw Exceptions::RuntimeErrorException("Error in runComputations: ISimulation has " - "terminated unexpectedly with following error: " - "message.\n" - + message); + throw std::runtime_error("Error in runComputations: ISimulation has " + "terminated unexpectedly with following error: " + "message.\n" + + message); } // Running computations in several threads. @@ -99,11 +99,10 @@ void runComputations(std::vector<std::unique_ptr<IComputation>>& computations) { if (failure_messages.empty()) return; - throw Exceptions::RuntimeErrorException( - "Error in runComputations: " - "At least one simulation thread has terminated unexpectedly.\n" - "Messages: " - + StringUtils::join(failure_messages, " --- ")); + throw std::runtime_error("Error in runComputations: " + "At least one simulation thread has terminated unexpectedly.\n" + "Messages: " + + StringUtils::join(failure_messages, " --- ")); } } // namespace diff --git a/Core/Simulation/OffSpecSimulation.cpp b/Core/Simulation/OffSpecSimulation.cpp index 5b33ab01b5c..a13b6e6b609 100644 --- a/Core/Simulation/OffSpecSimulation.cpp +++ b/Core/Simulation/OffSpecSimulation.cpp @@ -46,8 +46,8 @@ void OffSpecSimulation::setBeamParameters(double wavelength, const IAxis& alpha_ double phi_i) { m_alpha_i_axis.reset(alpha_axis.clone()); if (alpha_axis.size() < 1) - throw Exceptions::ClassInitializationException("OffSpecSimulation::prepareSimulation() " - "-> Error. Incoming alpha range size < 1."); + throw std::runtime_error("OffSpecSimulation::prepareSimulation() " + "-> Error. Incoming alpha range size < 1."); const double alpha_zero = alpha_axis.lowerBound(); instrument().setBeamParameters(wavelength, alpha_zero, phi_i); updateIntensityMap(); @@ -116,7 +116,7 @@ void OffSpecSimulation::transferResultsToIntensityMap() { const IAxis& phi_axis = instrument().getDetectorAxis(0); size_t phi_f_size = phi_axis.size(); if (phi_f_size * m_intensity_map.getAllocatedSize() != m_sim_elements.size()) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "OffSpecSimulation::transferResultsToIntensityMap: " "intensity map size does not conform to number of calculated intensities"); for (size_t i = 0; i < m_alpha_i_axis->size(); ++i) @@ -149,10 +149,10 @@ void OffSpecSimulation::transferDetectorImage(size_t index) { void OffSpecSimulation::checkInitialization() const { if (!m_alpha_i_axis || m_alpha_i_axis->size() < 1) - throw Exceptions::ClassInitializationException("OffSpecSimulation::checkInitialization() " - "Incoming alpha range not configured."); + throw std::runtime_error("OffSpecSimulation::checkInitialization() " + "Incoming alpha range not configured."); if (instrument().getDetectorDimension() != 2) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "OffSpecSimulation::checkInitialization: detector is not two-dimensional"); } diff --git a/Device/Beam/Beam.cpp b/Device/Beam/Beam.cpp index 958c5260fca..5e7386fb4d5 100644 --- a/Device/Beam/Beam.cpp +++ b/Device/Beam/Beam.cpp @@ -15,7 +15,6 @@ #include "Device/Beam/Beam.h" #include "Base/Math/Constants.h" #include "Base/Types/Complex.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Assert.h" #include "Device/Beam/FootprintGauss.h" #include "Param/Base/RealParameter.h" @@ -70,10 +69,10 @@ kvector_t Beam::getCentralK() const { void Beam::setCentralK(double wavelength, double alpha_i, double phi_i) { if (wavelength <= 0.0) - throw Exceptions::ClassInitializationException( + throw std::runtime_error( "Beam::setCentralK() -> Error. Wavelength can't be negative or zero."); if (alpha_i < 0.0) - throw Exceptions::ClassInitializationException( + throw std::runtime_error( "Beam::setCentralK() -> Error. Inclination angle alpha_i can't be negative."); m_wavelength = wavelength; m_alpha = alpha_i; @@ -98,7 +97,7 @@ void Beam::setWidthRatio(double width_ratio) { void Beam::setPolarization(const kvector_t bloch_vector) { if (bloch_vector.mag() > 1.0) { - throw Exceptions::ClassInitializationException( + throw std::runtime_error( "Beam::setPolarization: " "The given Bloch vector cannot represent a real physical ensemble"); } diff --git a/Device/Data/LLData.h b/Device/Data/LLData.h index fb76c6a0c6d..5f097da00f1 100644 --- a/Device/Data/LLData.h +++ b/Device/Data/LLData.h @@ -15,7 +15,6 @@ #ifndef BORNAGAIN_DEVICE_DATA_LLDATA_H #define BORNAGAIN_DEVICE_DATA_LLDATA_H -#include "Base/Types/Exceptions.h" #include "Base/Vector/EigenCore.h" #include <algorithm> #include <limits> @@ -126,7 +125,7 @@ template <class T> inline const T& LLData<T>::atCoordinate(int* coordinate) cons template <class T> LLData<T>& LLData<T>::operator+=(const LLData<T>& right) { if (!HaveSameDimensions(*this, right)) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "Operation += on LLData requires both operands to have the same dimensions"); for (size_t i = 0; i < getTotalSize(); ++i) { m_data_array[i] += right[i]; @@ -136,7 +135,7 @@ template <class T> LLData<T>& LLData<T>::operator+=(const LLData<T>& right) { template <class T> LLData<T>& LLData<T>::operator-=(const LLData& right) { if (!HaveSameDimensions(*this, right)) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "Operation -= on LLData requires both operands to have the same dimensions"); for (size_t i = 0; i < getTotalSize(); ++i) { m_data_array[i] -= right[i]; @@ -146,7 +145,7 @@ template <class T> LLData<T>& LLData<T>::operator-=(const LLData& right) { template <class T> LLData<T>& LLData<T>::operator*=(const LLData& right) { if (!HaveSameDimensions(*this, right)) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "Operation *= on LLData requires both operands to have the same dimensions"); for (size_t i = 0; i < getTotalSize(); ++i) { m_data_array[i] *= right[i]; @@ -156,7 +155,7 @@ template <class T> LLData<T>& LLData<T>::operator*=(const LLData& right) { template <class T> LLData<T>& LLData<T>::operator/=(const LLData& right) { if (!HaveSameDimensions(*this, right)) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "Operation /= on LLData requires both operands to have the same dimensions"); for (size_t i = 0; i < getTotalSize(); ++i) { double ratio; diff --git a/Device/Data/OutputData.cpp b/Device/Data/OutputData.cpp index 0a14b1aba67..10563f7cc68 100644 --- a/Device/Data/OutputData.cpp +++ b/Device/Data/OutputData.cpp @@ -38,7 +38,7 @@ template <> PyObject* OutputData<double>::getArray() const { PyObject* pyarray = PyArray_SimpleNew(ndim_numpy, ndimsizes_numpy, NPY_DOUBLE); delete[] ndimsizes_numpy; if (pyarray == nullptr) - throw Exceptions::RuntimeErrorException("ExportOutputData() -> Panic in PyArray_SimpleNew"); + throw std::runtime_error("ExportOutputData() -> Panic in PyArray_SimpleNew"); // getting pointer to data buffer of numpy array double* array_buffer = (double*)PyArray_DATA((PyArrayObject*)pyarray); diff --git a/Device/Data/OutputData.h b/Device/Data/OutputData.h index 41dc79b31c2..beb4a15a54f 100644 --- a/Device/Data/OutputData.h +++ b/Device/Data/OutputData.h @@ -280,10 +280,9 @@ template <class T> OutputData<double>* OutputData<T>::meanValues() const { template <class T> void OutputData<T>::addAxis(const IAxis& new_axis) { if (axisNameExists(new_axis.getName())) - throw Exceptions::LogicErrorException( - "OutputData<T>::addAxis(const IAxis& new_axis) -> " - "Error! Attempt to add axis with already existing name '" - + new_axis.getName() + "'"); + throw std::runtime_error("OutputData<T>::addAxis(const IAxis& new_axis) -> " + "Error! Attempt to add axis with already existing name '" + + new_axis.getName() + "'"); if (new_axis.size() > 0) { m_value_axes.push_back(new_axis.clone()); allocate(); @@ -293,10 +292,9 @@ template <class T> void OutputData<T>::addAxis(const IAxis& new_axis) { template <class T> void OutputData<T>::addAxis(const std::string& name, size_t size, double start, double end) { if (axisNameExists(name)) - throw Exceptions::LogicErrorException( - "OutputData<T>::addAxis(std::string name) -> " - "Error! Attempt to add axis with already existing name '" - + name + "'"); + throw std::runtime_error("OutputData<T>::addAxis(std::string name) -> " + "Error! Attempt to add axis with already existing name '" + + name + "'"); FixedBinAxis new_axis(name, size, start, end); addAxis(new_axis); } @@ -361,8 +359,8 @@ size_t OutputData<T>::getAxisBinIndex(size_t global_index, size_t i_selected_axi return result; remainder /= m_value_axes[i_axis]->size(); } - throw Exceptions::LogicErrorException("OutputData<T>::getAxisBinIndex() -> " - "Error! No axis with given number"); + throw std::runtime_error("OutputData<T>::getAxisBinIndex() -> " + "Error! No axis with given number"); } template <class T> @@ -374,9 +372,8 @@ template <class T> size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned>& axes_indices) const { ASSERT(m_ll_data); if (axes_indices.size() != m_ll_data->rank()) - throw Exceptions::LogicErrorException( - "size_t OutputData<T>::toGlobalIndex() -> " - "Error! Number of coordinates must match rank of data structure"); + throw std::runtime_error("size_t OutputData<T>::toGlobalIndex() -> " + "Error! Number of coordinates must match rank of data structure"); size_t result = 0; size_t step_size = 1; for (size_t i = m_ll_data->rank(); i > 0; --i) { @@ -386,7 +383,7 @@ size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned>& axes_indices) c message << axes_indices[i - 1] << " is out of range. Axis "; message << m_value_axes[i - 1]->getName(); message << " size " << m_value_axes[i - 1]->size() << ".\n"; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } result += axes_indices[i - 1] * step_size; step_size *= m_value_axes[i - 1]->size(); @@ -398,9 +395,8 @@ template <class T> size_t OutputData<T>::findGlobalIndex(const std::vector<double>& coordinates) const { ASSERT(m_ll_data); if (coordinates.size() != m_ll_data->rank()) - throw Exceptions::LogicErrorException( - "OutputData<T>::findClosestIndex() -> " - "Error! Number of coordinates must match rank of data structure"); + throw std::runtime_error("OutputData<T>::findClosestIndex() -> " + "Error! Number of coordinates must match rank of data structure"); std::vector<unsigned> axes_indexes; axes_indexes.resize(m_ll_data->rank()); for (size_t i = 0; i < m_ll_data->rank(); ++i) @@ -450,14 +446,14 @@ template <class T> void OutputData<T>::clear() { template <class T> void OutputData<T>::setAllTo(const T& value) { if (!m_ll_data) - throw Exceptions::ClassInitializationException( + throw std::runtime_error( "OutputData::setAllTo() -> Error! Low-level data object was not yet initialized."); m_ll_data->setAll(value); } template <class T> void OutputData<T>::scaleAll(const T& factor) { if (!m_ll_data) - throw Exceptions::ClassInitializationException( + throw std::runtime_error( "OutputData::scaleAll() -> Error! Low-level data object was not yet initialized."); m_ll_data->scaleAll(factor); } @@ -521,7 +517,7 @@ template <class T> void OutputData<T>::allocate() { template <class T> inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector) { if (data_vector.size() != getAllocatedSize()) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "OutputData<T>::setRawDataVector() -> Error! " "setRawDataVector can only be called with a data vector of the correct size."); for (size_t i = 0; i < getAllocatedSize(); ++i) @@ -572,9 +568,9 @@ template <class T> size_t OutputData<T>::getAxisIndex(const std::string& axis_na for (size_t i = 0; i < m_value_axes.size(); ++i) if (m_value_axes[i]->getName() == axis_name) return i; - throw Exceptions::LogicErrorException("OutputData<T>::getAxisIndex() -> " - "Error! Axis with given name not found '" - + axis_name + "'"); + throw std::runtime_error("OutputData<T>::getAxisIndex() -> " + "Error! Axis with given name not found '" + + axis_name + "'"); } template <class T> bool OutputData<T>::axisNameExists(const std::string& axis_name) const { diff --git a/Device/Detector/DetectionProperties.cpp b/Device/Detector/DetectionProperties.cpp index 7d828ceb3a1..fda9bf57d7e 100644 --- a/Device/Detector/DetectionProperties.cpp +++ b/Device/Detector/DetectionProperties.cpp @@ -14,7 +14,6 @@ #include "Device/Detector/DetectionProperties.h" #include "Base/Types/Complex.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" DetectionProperties::DetectionProperties(kvector_t direction, double efficiency, @@ -34,8 +33,8 @@ DetectionProperties::DetectionProperties(const DetectionProperties& other) void DetectionProperties::setAnalyzerProperties(const kvector_t direction, double efficiency, double total_transmission) { if (!checkAnalyzerProperties(direction, efficiency, total_transmission)) - throw Exceptions::ClassInitializationException("IDetector2D::setAnalyzerProperties: the " - "given properties are not physical"); + throw std::runtime_error("IDetector2D::setAnalyzerProperties: the " + "given properties are not physical"); if (efficiency == 0.0 || total_transmission == 0.0 || direction.mag() == 0.0) { m_direction = kvector_t{}; m_efficiency = 0.0; diff --git a/Device/Detector/DetectorMask.cpp b/Device/Detector/DetectorMask.cpp index 36ad3eb2592..61a56b618b6 100644 --- a/Device/Detector/DetectorMask.cpp +++ b/Device/Detector/DetectorMask.cpp @@ -46,8 +46,8 @@ void DetectorMask::addMask(const IShape2D& shape, bool mask_value) { void DetectorMask::initMaskData(const IDetector2D& detector) { if (detector.dimension() != 2) - throw Exceptions::RuntimeErrorException("DetectorMask::initMaskData() -> Error. Attempt " - "to add masks to uninitialized detector."); + throw std::runtime_error("DetectorMask::initMaskData() -> Error. Attempt " + "to add masks to uninitialized detector."); ASSERT(m_shapes.size() == m_mask_of_shape.size()); m_mask_data.clear(); diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index 93937f95138..853ca6f5586 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -71,10 +71,9 @@ size_t IDetector::axisBinIndex(size_t index, size_t selected_axis) const { std::unique_ptr<IAxis> IDetector::createAxis(size_t index, size_t n_bins, double min, double max) const { if (max <= min) - throw Exceptions::LogicErrorException("IDetector::createAxis() -> Error! max <= min"); + throw std::runtime_error("IDetector::createAxis() -> Error! max <= min"); if (n_bins == 0) - throw Exceptions::LogicErrorException( - "IDetector::createAxis() -> Error! Number n_bins can't be zero."); + throw std::runtime_error("IDetector::createAxis() -> Error! Number n_bins can't be zero."); return std::make_unique<FixedBinAxis>(axisName(index), n_bins, min, max); } @@ -135,8 +134,8 @@ OutputData<double>* IDetector::createDetectorIntensity(const std::vector<SimulationElement>& elements) const { std::unique_ptr<OutputData<double>> detectorMap(createDetectorMap()); if (!detectorMap) - throw Exceptions::RuntimeErrorException("Instrument::createDetectorIntensity:" - "can't create detector map."); + throw std::runtime_error("Instrument::createDetectorIntensity:" + "can't create detector map."); setDataToDetectorMap(*detectorMap, elements); if (m_detector_resolution) diff --git a/Device/Detector/IsGISAXSDetector.cpp b/Device/Detector/IsGISAXSDetector.cpp index 7d8c0545185..817ef6ef83d 100644 --- a/Device/Detector/IsGISAXSDetector.cpp +++ b/Device/Detector/IsGISAXSDetector.cpp @@ -36,11 +36,10 @@ IsGISAXSDetector* IsGISAXSDetector::clone() const { std::unique_ptr<IAxis> IsGISAXSDetector::createAxis(size_t index, size_t n_bins, double min, double max) const { if (max <= min) { - throw Exceptions::LogicErrorException( - "IsGISAXSDetector::createAxis() -> Error! max <= min"); + throw std::runtime_error("IsGISAXSDetector::createAxis() -> Error! max <= min"); } if (n_bins == 0) { - throw Exceptions::LogicErrorException( + throw std::runtime_error( "IsGISAXSDetector::createAxis() -> Error! Number n_bins can't be zero."); } return std::make_unique<CustomBinAxis>(axisName(index), n_bins, min, max); diff --git a/Device/Detector/RectangularDetector.cpp b/Device/Detector/RectangularDetector.cpp index 919d19d86aa..c78fe81e531 100644 --- a/Device/Detector/RectangularDetector.cpp +++ b/Device/Detector/RectangularDetector.cpp @@ -189,7 +189,7 @@ std::string RectangularDetector::axisName(size_t index) const { case 1: return "v"; default: - throw Exceptions::LogicErrorException( + throw std::runtime_error( "RectangularDetector::getAxisName(size_t index) -> Error! index > 1"); } } @@ -220,7 +220,7 @@ void RectangularDetector::setDistanceAndOffset(double distance, double u0, doubl std::ostringstream message; message << "RectangularDetector::setPerpendicularToSample() -> Error. " << "Distance to sample can't be negative or zero"; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } m_distance = distance; m_u0 = u0; @@ -249,8 +249,7 @@ void RectangularDetector::initNormalVector(const kvector_t central_k) { } else { - throw Exceptions::LogicErrorException( - "RectangularDetector::init() -> Unknown detector arrangement"); + throw std::runtime_error("RectangularDetector::init() -> Unknown detector arrangement"); } } diff --git a/Device/Detector/RegionOfInterest.cpp b/Device/Detector/RegionOfInterest.cpp index 3929ad4e917..acf838a3115 100644 --- a/Device/Detector/RegionOfInterest.cpp +++ b/Device/Detector/RegionOfInterest.cpp @@ -26,8 +26,8 @@ RegionOfInterest::RegionOfInterest(const OutputData<double>& data, double xlow, double xup, double yup) : RegionOfInterest(xlow, ylow, xup, yup) { if (data.rank() != 2) - throw Exceptions::RuntimeErrorException("RegionOfInterest::RegionOfInterest() -> Error. " - "Data is not two-dimensional."); + throw std::runtime_error("RegionOfInterest::RegionOfInterest() -> Error. " + "Data is not two-dimensional."); initFrom(data.axis(0), data.axis(1)); } @@ -81,11 +81,11 @@ size_t RegionOfInterest::detectorIndex(size_t roiIndex) const { size_t RegionOfInterest::roiIndex(size_t globalIndex) const { size_t ny = ycoord(globalIndex, m_detector_dims); if (ny < m_ay1 || ny > m_ay2) - throw Exceptions::RuntimeErrorException("RegionOfInterest::roiIndex() -> Error."); + throw std::runtime_error("RegionOfInterest::roiIndex() -> Error."); size_t nx = xcoord(globalIndex, m_detector_dims); if (nx < m_ax1 || nx > m_ax2) - throw Exceptions::RuntimeErrorException("RegionOfInterest::roiIndex() -> Error."); + throw std::runtime_error("RegionOfInterest::roiIndex() -> Error."); return ny - m_ay1 + (nx - m_ax1) * m_roi_dims[1]; } diff --git a/Device/Detector/SimulationAreaIterator.cpp b/Device/Detector/SimulationAreaIterator.cpp index 24f6f818291..906ac3b8f66 100644 --- a/Device/Detector/SimulationAreaIterator.cpp +++ b/Device/Detector/SimulationAreaIterator.cpp @@ -18,8 +18,8 @@ SimulationAreaIterator::SimulationAreaIterator(const SimulationArea* area, size_t start_at_index) : m_area(area), m_index(start_at_index), m_element_index(0) { if (m_index > m_area->totalSize()) - throw Exceptions::RuntimeErrorException("SimulationAreaIterator::SimulationAreaIterator() " - "-> Error. Invalid initial index"); + throw std::runtime_error("SimulationAreaIterator::SimulationAreaIterator() " + "-> Error. Invalid initial index"); if (m_index != m_area->totalSize() && m_area->isMasked(m_index)) m_index = nextIndex(m_index); diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp index eab85862c54..5f61a667587 100644 --- a/Device/Detector/SphericalDetector.cpp +++ b/Device/Detector/SphericalDetector.cpp @@ -60,7 +60,7 @@ std::string SphericalDetector::axisName(size_t index) const { case 1: return "alpha_f"; default: - throw Exceptions::LogicErrorException( + throw std::runtime_error( "SphericalDetector::getAxisName(size_t index) -> Error! index > 1"); } } diff --git a/Device/Histo/Histogram2D.cpp b/Device/Histo/Histogram2D.cpp index 34ef6e4ccc0..e123af7ed0f 100644 --- a/Device/Histo/Histogram2D.cpp +++ b/Device/Histo/Histogram2D.cpp @@ -119,7 +119,7 @@ void Histogram2D::addContent(const std::vector<std::vector<double>>& data) { << "] doesn't mach histogram axes. " << "X-axis size: " << m_data.axis(0).size() << "Y-axis size: " << m_data.axis(1).size(); - throw Exceptions::LogicErrorException(ostr.str()); + throw std::runtime_error(ostr.str()); } for (size_t row = 0; row < nrows; ++row) { diff --git a/Device/Histo/Histogram2D.h b/Device/Histo/Histogram2D.h index 0647ce939d3..7507cc960e0 100644 --- a/Device/Histo/Histogram2D.h +++ b/Device/Histo/Histogram2D.h @@ -117,8 +117,8 @@ template <typename T> void Histogram2D::initFromShape(const T& data) { const size_t ncols = shape.second; if (nrows == 0 || ncols == 0) - throw Exceptions::LogicErrorException("Histogram2D::Histogram2D() -> Error. " - "Not a two-dimensional numpy array"); + throw std::runtime_error("Histogram2D::Histogram2D() -> Error. " + "Not a two-dimensional numpy array"); m_data.addAxis(FixedBinAxis("x-axis", ncols, 0.0, static_cast<double>(ncols))); m_data.addAxis(FixedBinAxis("y-axis", nrows, 0.0, static_cast<double>(nrows))); diff --git a/Device/Histo/IHistogram.cpp b/Device/Histo/IHistogram.cpp index d80dc02c7f3..4d85c621f7a 100644 --- a/Device/Histo/IHistogram.cpp +++ b/Device/Histo/IHistogram.cpp @@ -211,7 +211,7 @@ IHistogram* IHistogram::createHistogram(const OutputData<double>& source) { message << "IHistogram::createHistogram(const OutputData<double>& source) -> Error. "; message << "The rank of source " << source.rank() << " "; message << "is not suitable for creation neither 1-dim nor 2-dim histograms."; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } } @@ -228,7 +228,7 @@ void IHistogram::check_x_axis() const { std::ostringstream message; message << "IHistogram::check_x_axis() -> Error. X-xis does not exist. "; message << "Rank of histogram " << rank() << "." << std::endl; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } } @@ -237,7 +237,7 @@ void IHistogram::check_y_axis() const { std::ostringstream message; message << "IHistogram::check_y_axis() -> Error. Y-axis does not exist. "; message << "Rank of histogram " << rank() << "." << std::endl; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } } @@ -247,7 +247,7 @@ void IHistogram::init_from_data(const OutputData<double>& source) { message << "IHistogram::IHistogram(const OutputData<double>& data) -> Error. "; message << "The dimension of this histogram " << rank() << " "; message << "is differ from the dimension of source " << m_data.rank() << std::endl; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } m_data.copyShapeFrom(source); @@ -267,7 +267,7 @@ double IHistogram::binData(size_t i, IHistogram::DataType dataType) const { } else if (dataType == DataType::NENTRIES) { return binNumberOfEntries(i); } else - throw Exceptions::LogicErrorException("IHistogram::binData() -> Error. Unknown data type."); + throw std::runtime_error("IHistogram::binData() -> Error. Unknown data type."); } //! returns vector of values of requested DataType @@ -283,7 +283,7 @@ std::vector<double> IHistogram::getDataVector(IHistogram::DataType dataType) con //! Copy content (but not the axes) from other histogram. Dimensions should be the same. void IHistogram::copyContentFrom(const IHistogram& other) { if (!hasSameDimensions(other)) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "IHistogram::copyContentFrom() -> Error. Can't copy the data of different shape."); reset(); for (size_t i = 0; i < getTotalNumberOfBins(); ++i) { @@ -311,7 +311,7 @@ bool IHistogram::hasSameDimensions(const IHistogram& other) const { const IHistogram& IHistogram::operator+=(const IHistogram& right) { if (!hasSameDimensions(right)) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "IHistogram::operator+=() -> Error. Histograms have different dimension"); for (size_t i = 0; i < getTotalNumberOfBins(); ++i) addBinContent(i, right.binContent(i)); @@ -320,8 +320,8 @@ const IHistogram& IHistogram::operator+=(const IHistogram& right) { IHistogram* IHistogram::relativeDifferenceHistogram(const IHistogram& rhs) { if (!hasSameDimensions(rhs)) - throw Exceptions::LogicErrorException("IHistogram::relativeDifferenceHistogram() -> Error. " - "Histograms have different dimensions"); + throw std::runtime_error("IHistogram::relativeDifferenceHistogram() -> Error. " + "Histograms have different dimensions"); IHistogram* result = this->clone(); result->reset(); diff --git a/Device/InputOutput/DataFormatUtils.cpp b/Device/InputOutput/DataFormatUtils.cpp index 7f3ae56bbbb..41cd8bb6f72 100644 --- a/Device/InputOutput/DataFormatUtils.cpp +++ b/Device/InputOutput/DataFormatUtils.cpp @@ -84,15 +84,15 @@ std::unique_ptr<IAxis> DataFormatUtils::createAxis(std::istream& input_stream) { auto iss = getAxisStringRepresentation(input_stream); std::string type; if (!(iss >> type)) - throw Exceptions::FormatErrorException( + throw std::runtime_error( "Error in DataFormatUtils::createAxis:: couldn't read axis type from input"); for (auto iter = type_map.cbegin(); iter != type_map.end(); ++iter) if (iter->first == type) return iter->second(std::move(iss)); - throw Exceptions::LogicErrorException("Error in DataFormatUtils::createAxis:" - "Unknown axis type '" - + type + "'"); + throw std::runtime_error("Error in DataFormatUtils::createAxis:" + "Unknown axis type '" + + type + "'"); } //! Fills output data raw buffer from input stream @@ -113,8 +113,7 @@ void DataFormatUtils::fillOutputData(OutputData<double>* data, std::istream& inp } } if (it != data->end()) - throw Exceptions::FormatErrorException( - "DataFormatUtils::fillOutputData() -> Error while parsing data."); + throw std::runtime_error("DataFormatUtils::fillOutputData() -> Error while parsing data."); } //! Parse double values from string to vector of double @@ -159,15 +158,13 @@ template <class Axis> std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istring std::string name; size_t nbins(0); if (!(iss >> name >> nbins)) - throw Exceptions::FormatErrorException( - "createFixedBinLikeAxis() -> Error. Can't parse the string."); + throw std::runtime_error("createFixedBinLikeAxis() -> Error. Can't parse the string."); std::vector<double> boundaries; DataFormatUtils::readLineOfDoubles(boundaries, iss); if (boundaries.size() != 2) - throw Exceptions::FormatErrorException( - "Error in createFixedBinLikeAxis: Can't parse the string while " - "reading boundaries."); + throw std::runtime_error("Error in createFixedBinLikeAxis: Can't parse the string while " + "reading boundaries."); return std::make_unique<Axis>(name, nbins, boundaries[0], boundaries[1]); } @@ -178,13 +175,12 @@ std::unique_ptr<IAxis> createVariableBinAxis(std::istringstream iss) { std::string name; size_t nbins(0); if (!(iss >> name >> nbins)) - throw Exceptions::FormatErrorException( - "Error in createVariableBinAxis: Can't parse the string."); + throw std::runtime_error("Error in createVariableBinAxis: Can't parse the string."); std::vector<double> boundaries; DataFormatUtils::readLineOfDoubles(boundaries, iss); if (boundaries.size() != nbins + 1) - throw Exceptions::FormatErrorException( + throw std::runtime_error( "Error in createVariableBinAxis: wrong number of boundaries read."); return std::make_unique<VariableBinAxis>(name, nbins, boundaries); @@ -195,8 +191,7 @@ std::unique_ptr<IAxis> createVariableBinAxis(std::istringstream iss) { std::unique_ptr<IAxis> createPointwiseAxis(std::istringstream iss) { std::string name; if (!(iss >> name)) - throw Exceptions::FormatErrorException( - "Error in createPointwiseAxis:Can't parse the string."); + throw std::runtime_error("Error in createPointwiseAxis:Can't parse the string."); std::vector<double> coordinates; DataFormatUtils::readLineOfDoubles(coordinates, iss); diff --git a/Device/InputOutput/OutputDataReadFactory.cpp b/Device/InputOutput/OutputDataReadFactory.cpp index 0c7986042b9..15160855589 100644 --- a/Device/InputOutput/OutputDataReadFactory.cpp +++ b/Device/InputOutput/OutputDataReadFactory.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Device/InputOutput/OutputDataReadFactory.h" -#include "Base/Types/Exceptions.h" #include "Device/InputOutput/DataFormatUtils.h" OutputDataReader* OutputDataReadFactory::getReader(const std::string& file_name) { diff --git a/Device/InputOutput/OutputDataReader.cpp b/Device/InputOutput/OutputDataReader.cpp index 0148f7dbf76..06b92dede28 100644 --- a/Device/InputOutput/OutputDataReader.cpp +++ b/Device/InputOutput/OutputDataReader.cpp @@ -50,7 +50,7 @@ OutputDataReader::OutputDataReader(const std::string& file_name) : m_file_name(f OutputData<double>* OutputDataReader::getOutputData() { using namespace DataFormatUtils; if (!m_read_strategy) - throw Exceptions::NullPointerException( + throw std::runtime_error( "OutputDataReader::getOutputData() -> Error! No read strategy defined"); std::ifstream fin; @@ -65,12 +65,11 @@ OutputData<double>* OutputDataReader::getOutputData() { #endif if (!fin.is_open()) - throw Exceptions::FileNotIsOpenException( - "OutputDataReader::getOutputData() -> Error. Can't open file '" + m_file_name - + "' for reading."); + throw std::runtime_error("OutputDataReader::getOutputData() -> Error. Can't open file '" + + m_file_name + "' for reading."); if (!fin.good()) - throw Exceptions::FileIsBadException("OutputDataReader::getOutputData() -> Error! " - "File is not good, probably it is a directory."); + throw std::runtime_error("OutputDataReader::getOutputData() -> Error! " + "File is not good, probably it is a directory."); std::stringstream strstream = getFromFilteredStream(fin, m_file_name); diff --git a/Device/InputOutput/OutputDataWriteFactory.cpp b/Device/InputOutput/OutputDataWriteFactory.cpp index e88da3abca0..4e19cd0b6f4 100644 --- a/Device/InputOutput/OutputDataWriteFactory.cpp +++ b/Device/InputOutput/OutputDataWriteFactory.cpp @@ -12,7 +12,6 @@ // // ************************************************************************************************ #include "Device/InputOutput/OutputDataWriteFactory.h" -#include "Base/Types/Exceptions.h" #include "Device/InputOutput/DataFormatUtils.h" OutputDataWriter* OutputDataWriteFactory::getWriter(const std::string& file_name) { diff --git a/Device/InputOutput/OutputDataWriter.cpp b/Device/InputOutput/OutputDataWriter.cpp index b93c022d784..acaa1688eed 100644 --- a/Device/InputOutput/OutputDataWriter.cpp +++ b/Device/InputOutput/OutputDataWriter.cpp @@ -31,8 +31,8 @@ OutputDataWriter::OutputDataWriter(const std::string& file_name) : m_file_name(f void OutputDataWriter::writeOutputData(const OutputData<double>& data) { using namespace DataFormatUtils; if (!m_write_strategy) - throw Exceptions::NullPointerException("OutputDataWriter::getOutputData() ->" - " Error! No read strategy defined"); + throw std::runtime_error("OutputDataWriter::getOutputData() ->" + " Error! No read strategy defined"); std::ofstream fout; std::ios_base::openmode openmode = std::ios::out; @@ -46,12 +46,12 @@ void OutputDataWriter::writeOutputData(const OutputData<double>& data) { #endif if (!fout.is_open()) - throw Exceptions::FileNotIsOpenException("OutputDataWriter::writeOutputData() -> Error. " - "Can't open file '" - + m_file_name + "' for writing."); + throw std::runtime_error("OutputDataWriter::writeOutputData() -> Error. " + "Can't open file '" + + m_file_name + "' for writing."); if (!fout.good()) - throw Exceptions::FileIsBadException("OutputDataReader::writeOutputData() -> Error! " - "File is not good, probably it is a directory."); + throw std::runtime_error("OutputDataReader::writeOutputData() -> Error! " + "File is not good, probably it is a directory."); std::stringstream ss; m_write_strategy->writeOutputData(data, ss); diff --git a/Device/InputOutput/TiffHandler.cpp b/Device/InputOutput/TiffHandler.cpp index 1704132757a..68672fde466 100644 --- a/Device/InputOutput/TiffHandler.cpp +++ b/Device/InputOutput/TiffHandler.cpp @@ -33,7 +33,7 @@ TiffHandler::~TiffHandler() { void TiffHandler::read(std::istream& input_stream) { m_tiff = TIFFStreamOpen("MemTIFF", &input_stream); if (!m_tiff) { - throw Exceptions::FormatErrorException("TiffHandler::read() -> Can't open the file."); + throw std::runtime_error("TiffHandler::read() -> Can't open the file."); } read_header(); read_data(); @@ -47,8 +47,8 @@ const OutputData<double>* TiffHandler::getOutputData() const { void TiffHandler::write(const OutputData<double>& data, std::ostream& output_stream) { m_data.reset(data.clone()); if (m_data->rank() != 2) - throw Exceptions::LogicErrorException("TiffHandler::write -> Error. " - "Only 2-dim arrays supported"); + throw std::runtime_error("TiffHandler::write -> Error. " + "Only 2-dim arrays supported"); m_tiff = TIFFStreamOpen("MemTIFF", &output_stream); m_width = m_data->axis(0).size(); m_height = m_data->axis(1).size(); // this does not exist for 1d data @@ -63,8 +63,8 @@ void TiffHandler::read_header() { uint32 height(0); if (!TIFFGetField(m_tiff, TIFFTAG_IMAGEWIDTH, &width) || !TIFFGetField(m_tiff, TIFFTAG_IMAGELENGTH, &height)) { - throw Exceptions::FormatErrorException("TiffHandler::read_header() -> Error. " - "Can't read width/height."); + throw std::runtime_error("TiffHandler::read_header() -> Error. " + "Can't read width/height."); } m_width = (size_t)width; @@ -109,7 +109,7 @@ void TiffHandler::read_header() { << " TIFFTAG_BITSPERSAMPLE: " << m_bitsPerSample << std::endl << " TIFFTAG_SAMPLESPERPIXEL: " << m_samplesPerPixel << std::endl << " TIFFTAG_SAMPLEFORMAT: " << m_sampleFormat << std::endl; - throw Exceptions::FormatErrorException(message.str()); + throw std::runtime_error(message.str()); } } @@ -121,13 +121,11 @@ void TiffHandler::read_data() { tmsize_t buf_size = TIFFScanlineSize(m_tiff); tmsize_t expected_size = bytesPerSample * m_width; if (buf_size != expected_size) - throw Exceptions::FormatErrorException( - "TiffHandler::read_data() -> Error. Wrong scanline size."); + throw std::runtime_error("TiffHandler::read_data() -> Error. Wrong scanline size."); tdata_t buf = _TIFFmalloc(buf_size); if (!buf) - throw Exceptions::FormatErrorException( - "TiffHandler::read_data() -> Error. Can't allocate buffer."); + throw std::runtime_error("TiffHandler::read_data() -> Error. Can't allocate buffer."); create_output_data(); @@ -138,8 +136,7 @@ void TiffHandler::read_data() { for (uint32 row = 0; row < (uint32)m_height; row++) { if (TIFFReadScanline(m_tiff, buf, row) < 0) - throw Exceptions::FormatErrorException( - "TiffHandler::read_data() -> Error. Error in scanline."); + throw std::runtime_error("TiffHandler::read_data() -> Error. Error in scanline."); memcpy(&line_buf[0], buf, buf_size); @@ -182,7 +179,7 @@ void TiffHandler::read_data() { sample = double(*reinterpret_cast<float*>(incoming)); break; default: - throw Exceptions::FormatErrorException("TiffHandler: unexpected sample format"); + throw std::runtime_error("TiffHandler: unexpected sample format"); } (*m_data)[global_index] = sample; @@ -217,8 +214,7 @@ void TiffHandler::write_data() { tmsize_t buf_size = sizeof(sample_t) * m_width; tdata_t buf = _TIFFmalloc(buf_size); if (!buf) - throw Exceptions::FormatErrorException( - "TiffHandler::write_data() -> Error. Can't allocate buffer."); + throw std::runtime_error("TiffHandler::write_data() -> Error. Can't allocate buffer."); std::vector<sample_t> line_buf; line_buf.resize(m_width, 0); @@ -233,7 +229,7 @@ void TiffHandler::write_data() { memcpy(buf, &line_buf[0], buf_size); if (TIFFWriteScanline(m_tiff, buf, row) < 0) - throw Exceptions::FormatErrorException( + throw std::runtime_error( "TiffHandler::write_data() -> Error. Error in TIFFWriteScanline."); } _TIFFfree(buf); diff --git a/Device/Instrument/FourierTransform.cpp b/Device/Instrument/FourierTransform.cpp index d524989146b..3805beacb56 100644 --- a/Device/Instrument/FourierTransform.cpp +++ b/Device/Instrument/FourierTransform.cpp @@ -14,7 +14,6 @@ // ************************************************************************************************ #include "Device/Instrument/FourierTransform.h" -#include "Base/Types/Exceptions.h" #include <algorithm> #include <cmath> #include <iostream> @@ -124,7 +123,7 @@ void FourierTransform::fft(const double1d_t& source, double1d_t& result) { fft(source2d, result2d); if (result2d.size() != 1) - throw Exceptions::RuntimeErrorException("FourierTransform::fft -> Panic in 1d"); + throw std::runtime_error("FourierTransform::fft -> Panic in 1d"); result = result2d[0]; } @@ -151,7 +150,7 @@ void FourierTransform::init(int h_src, int w_src) { std::ostringstream os; os << "FourierTransform::init() -> Panic! Wrong dimensions " << h_src << " " << w_src << std::endl; - throw Exceptions::RuntimeErrorException(os.str()); + throw std::runtime_error(os.str()); } ws.clear(); @@ -172,7 +171,7 @@ void FourierTransform::init(int h_src, int w_src) { // static_cast<double*>(ws.out_src), FFTW_ESTIMATE); if (ws.p_forw_src == nullptr) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "FourierTransform::init() -> Error! Can't initialise p_forw_src plan."); } @@ -182,7 +181,7 @@ void FourierTransform::init(int h_src, int w_src) { void FourierTransform::fftw_forward_FT(const double2d_t& src) { if (ws.h_fftw <= 0 || ws.w_fftw <= 0) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "FourierTransform::fftw_forward_FT() -> Panic! Initialisation is missed."); double *ptr, *ptr_end; diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp index 6fab0c1e693..8df69595b7b 100644 --- a/Device/Instrument/Instrument.cpp +++ b/Device/Instrument/Instrument.cpp @@ -50,7 +50,7 @@ void Instrument::setDetector(const IDetector& detector) { void Instrument::initDetector() { if (!m_detector) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "Instrument::initDetector() -> Error. Detector is not initialized."); m_detector->init(beam()); } diff --git a/Device/Instrument/IntensityDataFunctions.cpp b/Device/Instrument/IntensityDataFunctions.cpp index 6faa28376e2..bded700dbea 100644 --- a/Device/Instrument/IntensityDataFunctions.cpp +++ b/Device/Instrument/IntensityDataFunctions.cpp @@ -43,9 +43,8 @@ double IntensityDataFunctions::RelativeDifference(const SimulationResult& dat, double IntensityDataFunctions::getRelativeDifference(const OutputData<double>& dat, const OutputData<double>& ref) { if (!dat.hasSameDimensions(ref)) - throw Exceptions::RuntimeErrorException( - "IntensityDataFunctions::getRelativeDifference() -> " - "Error. Different dimensions of data and reference."); + throw std::runtime_error("IntensityDataFunctions::getRelativeDifference() -> " + "Error. Different dimensions of data and reference."); double diff = 0.0; for (size_t i = 0; i < dat.getAllocatedSize(); ++i) @@ -53,7 +52,7 @@ double IntensityDataFunctions::getRelativeDifference(const OutputData<double>& d diff /= dat.getAllocatedSize(); if (std::isnan(diff)) - throw Exceptions::RuntimeErrorException("diff=NaN!"); + throw std::runtime_error("diff=NaN!"); return diff; } @@ -84,9 +83,8 @@ std::unique_ptr<OutputData<double>> IntensityDataFunctions::createRelativeDifferenceData(const OutputData<double>& data, const OutputData<double>& reference) { if (!data.hasSameDimensions(reference)) - throw Exceptions::RuntimeErrorException( - "IntensityDataFunctions::createRelativeDifferenceData() -> " - "Error. Different dimensions of data and reference."); + throw std::runtime_error("IntensityDataFunctions::createRelativeDifferenceData() -> " + "Error. Different dimensions of data and reference."); std::unique_ptr<OutputData<double>> result(reference.clone()); for (size_t i = 0; i < result->getAllocatedSize(); ++i) (*result)[i] = Numeric::GetRelativeDifference(data[i], reference[i]); @@ -96,8 +94,8 @@ IntensityDataFunctions::createRelativeDifferenceData(const OutputData<double>& d std::unique_ptr<OutputData<double>> IntensityDataFunctions::createRearrangedDataSet(const OutputData<double>& data, int n) { if (data.rank() != 2) - throw Exceptions::LogicErrorException("IntensityDataFunctions::rotateDataByN90Deg()" - " -> Error! Works only on two-dimensional data"); + throw std::runtime_error("IntensityDataFunctions::rotateDataByN90Deg()" + " -> Error! Works only on two-dimensional data"); n = (4 + n % 4) % 4; if (n == 0) return std::unique_ptr<OutputData<double>>(data.clone()); @@ -142,8 +140,8 @@ std::unique_ptr<OutputData<double>> IntensityDataFunctions::createClippedDataSet(const OutputData<double>& origin, double x1, double y1, double x2, double y2) { if (origin.rank() != 2) - throw Exceptions::LogicErrorException("IntensityDataFunctions::createClippedData()" - " -> Error! Works only on two-dimensional data"); + throw std::runtime_error("IntensityDataFunctions::createClippedData()" + " -> Error! Works only on two-dimensional data"); std::unique_ptr<OutputData<double>> result(new OutputData<double>); for (size_t i_axis = 0; i_axis < origin.rank(); i_axis++) { @@ -219,9 +217,8 @@ void IntensityDataFunctions::coordinateFromBinf(double& x, double& y, std::vector<std::vector<double>> IntensityDataFunctions::create2DArrayfromOutputData(const OutputData<double>& data) { if (data.rank() != 2) - throw Exceptions::LogicErrorException( - "IntensityDataFunctions::create2DArrayfromOutputData() -> " - "Error! Works only on two-dimensional data"); + throw std::runtime_error("IntensityDataFunctions::create2DArrayfromOutputData() -> " + "Error! Works only on two-dimensional data"); std::vector<std::vector<double>> array_2d; std::vector<double> row_vec; // row vector for constructing each row of 2D array diff --git a/Device/Intensity/ArrayUtils.cpp b/Device/Intensity/ArrayUtils.cpp index 0a896fc4929..7f7ddd69926 100644 --- a/Device/Intensity/ArrayUtils.cpp +++ b/Device/Intensity/ArrayUtils.cpp @@ -27,7 +27,7 @@ PyObject* ArrayUtils::createNumpyArray(const std::vector<double>& data) { PyObject* pyarray = PyArray_SimpleNew(ndim_numpy, ndimsizes_numpy, NPY_DOUBLE); delete[] ndimsizes_numpy; if (pyarray == nullptr) - throw Exceptions::RuntimeErrorException("ExportOutputData() -> Panic in PyArray_SimpleNew"); + throw std::runtime_error("ExportOutputData() -> Panic in PyArray_SimpleNew"); // getting pointer to data buffer of numpy array double* array_buffer = (double*)PyArray_DATA((PyArrayObject*)pyarray); diff --git a/Device/Mask/Ellipse.cpp b/Device/Mask/Ellipse.cpp index 6084c13da94..787a0fa6c06 100644 --- a/Device/Mask/Ellipse.cpp +++ b/Device/Mask/Ellipse.cpp @@ -14,7 +14,6 @@ #include "Device/Mask/Ellipse.h" #include "Base/Axis/Bin.h" -#include "Base/Types/Exceptions.h" //! @param xcenter x-coordinate of Ellipse's center //! @param ycenter y-coordinate of Ellipse's center @@ -29,7 +28,7 @@ Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius, , m_yr(yradius) , m_theta(theta) { if (xradius <= 0.0 || yradius <= 0.0) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius) " "-> Error. Radius can't be negative\n"); } diff --git a/Device/Mask/Polygon.cpp b/Device/Mask/Polygon.cpp index e84f449771b..05b74e9db94 100644 --- a/Device/Mask/Polygon.cpp +++ b/Device/Mask/Polygon.cpp @@ -14,7 +14,6 @@ #include "Device/Mask/Polygon.h" #include "Base/Axis/Bin.h" -#include "Base/Types/Exceptions.h" #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> @@ -34,7 +33,7 @@ public: void PolygonPrivate::init_from(const std::vector<double>& x, const std::vector<double>& y) { if (x.size() != y.size()) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "Polygon::Polygon(const std::vector<double>& x, const std::vector<double>& y) " "Error. Sizes of arrays must conincide."); std::vector<point_t> points; @@ -76,7 +75,7 @@ Polygon::Polygon(const std::vector<std::vector<double>> points) std::vector<double> y; for (size_t i = 0; i < points.size(); ++i) { if (points[i].size() != 2) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "Polygon(const std::vector<std::vector<double> >& points) -> Error. " " Should be two-dimensional array with second dimension of 2 size."); x.push_back(points[i][0]); diff --git a/Device/Mask/Rectangle.cpp b/Device/Mask/Rectangle.cpp index c47ac24dcdb..7f170547093 100644 --- a/Device/Mask/Rectangle.cpp +++ b/Device/Mask/Rectangle.cpp @@ -14,7 +14,6 @@ #include "Device/Mask/Rectangle.h" #include "Base/Axis/Bin.h" -#include "Base/Types/Exceptions.h" //! @param xlow x-coordinate of lower left corner //! @param ylow y-coordinate of lower left corner @@ -25,13 +24,13 @@ Rectangle::Rectangle(double xlow, double ylow, double xup, double yup) : IShape2 std::ostringstream message; message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. "; message << " xup <= xlow" << std::endl; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } if (yup <= ylow) { std::ostringstream message; message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. "; message << " yup <= ylow" << std::endl; - throw Exceptions::LogicErrorException(message.str()); + throw std::runtime_error(message.str()); } m_xlow = xlow; m_ylow = ylow; diff --git a/Device/Resolution/ConvolutionDetectorResolution.cpp b/Device/Resolution/ConvolutionDetectorResolution.cpp index 3e2e30d83f3..f75598b17f1 100644 --- a/Device/Resolution/ConvolutionDetectorResolution.cpp +++ b/Device/Resolution/ConvolutionDetectorResolution.cpp @@ -49,7 +49,7 @@ std::vector<const INode*> ConvolutionDetectorResolution::getChildren() const { void ConvolutionDetectorResolution::applyDetectorResolution( OutputData<double>* p_intensity_map) const { if (p_intensity_map->rank() != m_dimension) { - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "ConvolutionDetectorResolution::applyDetectorResolution() -> Error! " "Intensity map must have same dimension as detector resolution function."); } @@ -61,7 +61,7 @@ void ConvolutionDetectorResolution::applyDetectorResolution( apply2dConvolution(p_intensity_map); break; default: - throw Exceptions::LogicErrorException( + throw std::runtime_error( "ConvolutionDetectorResolution::applyDetectorResolution() -> Error! " "Class ConvolutionDetectorResolution must be initialized with dimension 1 or 2."); } @@ -74,11 +74,10 @@ void ConvolutionDetectorResolution::setResolutionFunction(const IResolutionFunct void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_intensity_map) const { if (m_res_function_1d == 0) - throw Exceptions::LogicErrorException( - "ConvolutionDetectorResolution::apply1dConvolution() -> Error! " - "No 1d resolution function present for convolution of 1d data."); + throw std::runtime_error("ConvolutionDetectorResolution::apply1dConvolution() -> Error! " + "No 1d resolution function present for convolution of 1d data."); if (p_intensity_map->rank() != 1) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "ConvolutionDetectorResolution::apply1dConvolution() -> Error! " "Number of axes for intensity map does not correspond to the dimension of the map."); const IAxis& axis = p_intensity_map->axis(0); @@ -89,7 +88,7 @@ void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_int return; // No convolution for sets of zero or one element // Construct kernel vector from resolution function if (axis.size() != data_size) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "ConvolutionDetectorResolution::apply1dConvolution() -> Error! " "Size of axis for intensity map does not correspond to size of data in the map."); double step_size = std::abs(axis[0] - axis[axis.size() - 1]) / (data_size - 1); @@ -109,11 +108,10 @@ void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_int void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_intensity_map) const { if (m_res_function_2d == 0) - throw Exceptions::LogicErrorException( - "ConvolutionDetectorResolution::apply2dConvolution() -> Error! " - "No 2d resolution function present for convolution of 2d data."); + throw std::runtime_error("ConvolutionDetectorResolution::apply2dConvolution() -> Error! " + "No 2d resolution function present for convolution of 2d data."); if (p_intensity_map->rank() != 2) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "ConvolutionDetectorResolution::apply2dConvolution() -> Error! " "Number of axes for intensity map does not correspond to the dimension of the map."); const IAxis& axis_1 = p_intensity_map->axis(0); @@ -127,7 +125,7 @@ void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_int std::vector<std::vector<double>> source; size_t raw_data_size = raw_source_vector.size(); if (raw_data_size != axis_size_1 * axis_size_2) - throw Exceptions::LogicErrorException( + throw std::runtime_error( "ConvolutionDetectorResolution::apply2dConvolution() -> Error! " "Intensity map data size does not match the product of its axes' sizes"); for (auto it = raw_source_vector.begin(); it != raw_source_vector.end(); it += axis_size_2) { diff --git a/Device/Resolution/Convolve.cpp b/Device/Resolution/Convolve.cpp index 91d348c4e1f..a5afe95e2ac 100644 --- a/Device/Resolution/Convolve.cpp +++ b/Device/Resolution/Convolve.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Device/Resolution/Convolve.h" -#include "Base/Types/Exceptions.h" #include <iostream> #include <sstream> #include <stdexcept> // need overlooked by g++ 5.4 @@ -139,7 +138,7 @@ void Convolve::fftconvolve(const double1d_t& source, const double1d_t& kernel, d double2d_t result2d; fftconvolve(source2d, kernel2d, result2d); if (result2d.size() != 1) - throw Exceptions::RuntimeErrorException("Convolve::fftconvolve -> Panic in 1d"); + throw std::runtime_error("Convolve::fftconvolve -> Panic in 1d"); result = result2d[0]; } @@ -151,7 +150,7 @@ void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel) { std::ostringstream os; os << "Convolve::init() -> Panic! Wrong dimensions " << h_src << " " << w_src << " " << h_kernel << " " << w_kernel << std::endl; - throw Exceptions::RuntimeErrorException(os.str()); + throw std::runtime_error(os.str()); } ws.clear(); @@ -245,21 +244,18 @@ void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel) { ws.p_forw_src = fftw_plan_dft_r2c_2d(ws.h_fftw, ws.w_fftw, ws.in_src, (fftw_complex*)ws.out_src, FFTW_ESTIMATE); if (ws.p_forw_src == nullptr) - throw Exceptions::RuntimeErrorException( - "Convolve::init() -> Error! Can't initialise p_forw_src plan."); + throw std::runtime_error("Convolve::init() -> Error! Can't initialise p_forw_src plan."); ws.p_forw_kernel = fftw_plan_dft_r2c_2d(ws.h_fftw, ws.w_fftw, ws.in_kernel, (fftw_complex*)ws.out_kernel, FFTW_ESTIMATE); if (ws.p_forw_kernel == nullptr) - throw Exceptions::RuntimeErrorException( - "Convolve::init() -> Error! Can't initialise p_forw_kernel plan."); + throw std::runtime_error("Convolve::init() -> Error! Can't initialise p_forw_kernel plan."); // The backward FFT takes ws.out_kernel as input ws.p_back = fftw_plan_dft_c2r_2d(ws.h_fftw, ws.w_fftw, (fftw_complex*)ws.out_kernel, ws.dst_fft, FFTW_ESTIMATE); if (ws.p_back == nullptr) - throw Exceptions::RuntimeErrorException( - "Convolve::init() -> Error! Can't initialise p_back plan."); + throw std::runtime_error("Convolve::init() -> Error! Can't initialise p_back plan."); } /* ************************************************************************* */ @@ -268,8 +264,7 @@ void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel) { void Convolve::fftw_circular_convolution(const double2d_t& src, const double2d_t& kernel) { if (ws.h_fftw <= 0 || ws.w_fftw <= 0) - throw Exceptions::RuntimeErrorException( - "Convolve::fftw_convolve() -> Panic! Initialisation is missed."); + throw std::runtime_error("Convolve::fftw_convolve() -> Panic! Initialisation is missed."); double *ptr, *ptr_end, *ptr2; diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp index 5a822910415..cfc43d2bdbc 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp @@ -260,8 +260,7 @@ void CsvImportAssistant::removeBlankColumns() { size_t nCols = m_csvArray[0].size(); if (!hasEqualLengthLines(m_csvArray)) { - throw Exceptions::NotImplementedException( - "All inner vectors should have the same length already."); + throw std::runtime_error("All inner vectors should have the same length already."); } // traverse the array columnwise -- this may be inneficient. diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp index 72b56b88098..a4ade568210 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.cpp @@ -14,7 +14,6 @@ #include "GUI/coregui/Views/RealSpaceWidgets/RealSpaceBuilderUtils.h" #include "Base/Const/Units.h" -#include "Base/Types/Exceptions.h" #include "GUI/coregui/Models/InterferenceFunctionItems.h" #include "GUI/coregui/Models/Lattice2DItems.h" #include "GUI/coregui/Models/LayerItem.h" @@ -350,7 +349,7 @@ Particle3DContainer RealSpaceBuilderUtils::particleComposition3DContainer( std::ostringstream ostr; ostr << "Sorry, MesoCrystal inside ParticleComposition not yet implemented"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else { auto particle = dynamic_cast<const Particle*>(pc_particle); particle3DContainer = singleParticle3DContainer(*particle, 1.0, origin); @@ -391,7 +390,7 @@ std::vector<Particle3DContainer> RealSpaceBuilderUtils::particleDistribution3DCo std::ostringstream ostr; ostr << "Sorry, MesoCrystal inside ParticleDistribution not yet implemented"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else { auto particle = dynamic_cast<const Particle*>(pd_particle); particle3DContainer = singleParticle3DContainer(*particle, total_abundance, origin); diff --git a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp index 05b00758dad..10010f66fab 100644 --- a/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp +++ b/GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.cpp @@ -14,7 +14,6 @@ #include "GUI/coregui/Views/RealSpaceWidgets/RealSpaceMesoCrystalUtils.h" #include "Base/Const/Units.h" -#include "Base/Types/Exceptions.h" #include "GUI/coregui/Models/Lattice2DItems.h" #include "GUI/coregui/Models/MesoCrystalItem.h" #include "GUI/coregui/Models/ParticleCompositionItem.h" @@ -136,12 +135,12 @@ bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positi std::ostringstream ostr; ostr << "Sorry, outer shape Dodecahedron not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (dynamic_cast<const FormFactorDot*>(outerShape)) { std::ostringstream ostr; ostr << "Cannot display particles inside the Mesocrystal!"; ostr << "\n\nOuter shape is a Dot!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (auto ff_EllipsoidalCylinder = dynamic_cast<const FormFactorEllipsoidalCylinder*>(outerShape)) { double a = ff_EllipsoidalCylinder->getRadiusX(); // semi-axis length along x @@ -196,7 +195,7 @@ bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positi std::ostringstream ostr; ostr << "Sorry, outer shape Icosahedron not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (auto ff_Prism3 = dynamic_cast<const FormFactorPrism3*>(outerShape)) { double B = ff_Prism3->getBaseEdge(); double H = ff_Prism3->getHeight(); @@ -254,37 +253,37 @@ bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positi std::ostringstream ostr; ostr << "Sorry, outer shape CosineRippleBox not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (dynamic_cast<const FormFactorCosineRippleGauss*>(outerShape)) { // TODO: Implement CosineRippleGauss std::ostringstream ostr; ostr << "Sorry, outer shape CosineRippleGauss not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (dynamic_cast<const FormFactorCosineRippleLorentz*>(outerShape)) { // TODO: Implement CosineRippleLorentz std::ostringstream ostr; ostr << "Sorry, outer shape CosineRippleLorentz not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (dynamic_cast<const FormFactorSawtoothRippleBox*>(outerShape)) { // TODO: Implement SawtoothRippleBox std::ostringstream ostr; ostr << "Sorry, outer shape SawtoothRippleBox not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (dynamic_cast<const FormFactorSawtoothRippleGauss*>(outerShape)) { // TODO: Implement SawtoothRippleGauss std::ostringstream ostr; ostr << "Sorry, outer shape SawtoothRippleGauss not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (dynamic_cast<const FormFactorSawtoothRippleLorentz*>(outerShape)) { // TODO: Implement SawtoothRippleLorentz std::ostringstream ostr; ostr << "Sorry, outer shape SawtoothRippleLorentz not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (auto ff_Tetrahedron = dynamic_cast<const FormFactorTetrahedron*>(outerShape)) { double B = ff_Tetrahedron->getBaseEdge(); double H = ff_Tetrahedron->getHeight(); @@ -317,7 +316,7 @@ bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positi std::ostringstream ostr; ostr << "Sorry, outer shape Truncated cube not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else if (auto ff_TruncatedSphere = dynamic_cast<const FormFactorTruncatedSphere*>(outerShape)) { double R = ff_TruncatedSphere->getRadius(); @@ -336,7 +335,7 @@ bool isPositionInsideMesoCrystal(const IFormFactor* outerShape, kvector_t positi std::ostringstream ostr; ostr << "Sorry, outer shape Truncated spheroid not yet implemented for Mesocrystal"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } return check; } @@ -381,7 +380,7 @@ Particle3DContainer RealSpaceMesoCrystal::populateMesoCrystal() { std::ostringstream ostr; ostr << "Sorry, MesoCrystal inside MesoCrystal not yet implemented"; ostr << "\n\nStay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } else { auto particle = dynamic_cast<const Particle*>(particleBasis.get()); mesoCrystalBasis3DContainer = diff --git a/Param/Base/IParameterized.cpp b/Param/Base/IParameterized.cpp index db193af0b62..8d5327636f8 100644 --- a/Param/Base/IParameterized.cpp +++ b/Param/Base/IParameterized.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Param/Base/IParameterized.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include <iostream> diff --git a/Param/Base/ParameterPool.cpp b/Param/Base/ParameterPool.cpp index 67f49f91c51..4d9b273a8c8 100644 --- a/Param/Base/ParameterPool.cpp +++ b/Param/Base/ParameterPool.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Param/Base/ParameterPool.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Assert.h" #include "Base/Utils/StringUtils.h" #include "Param/Base/RealParameter.h" @@ -55,10 +54,9 @@ void ParameterPool::clear() { RealParameter& ParameterPool::addParameter(RealParameter* newPar) { for (const auto* par : m_params) if (par->getName() == newPar->getName()) - throw Exceptions::RuntimeErrorException("ParameterPool::addParameter() -> Error. " - "Parameter '" - + newPar->getName() - + "' is already registered"); + throw std::runtime_error("ParameterPool::addParameter() -> Error. " + "Parameter '" + + newPar->getName() + "' is already registered"); m_params.push_back(newPar); return *newPar; } @@ -106,11 +104,11 @@ std::vector<RealParameter*> ParameterPool::getMatchedParameters(const std::strin RealParameter* ParameterPool::getUniqueMatch(const std::string& pattern) const { std::vector<RealParameter*> matches = getMatchedParameters(pattern); if (matches.empty()) - throw Exceptions::RuntimeErrorException( - "ParameterPool::getUniqueMatch: there is no match for '" + pattern + "'"); + throw std::runtime_error("ParameterPool::getUniqueMatch: there is no match for '" + pattern + + "'"); if (matches.size() != 1) - throw Exceptions::RuntimeErrorException("ParameterPool::getUniqueMatch: pattern '" + pattern - + "' is not unique"); + throw std::runtime_error("ParameterPool::getUniqueMatch: pattern '" + pattern + + "' is not unique"); return matches[0]; } @@ -128,7 +126,7 @@ void ParameterPool::setParameterValue(const std::string& name, double value) { message << "ParameterPool::getParameter() -> Warning. No parameter with name '" + name + "'\n" << "Available parameters:" << *this; - throw Exceptions::RuntimeErrorException(message.str()); + throw std::runtime_error(message.str()); } } @@ -153,8 +151,8 @@ int ParameterPool::setMatchedParametersValue(const std::string& pattern, double void ParameterPool::setUniqueMatchValue(const std::string& pattern, double value) { if (setMatchedParametersValue(pattern, value) != 1) - throw Exceptions::RuntimeErrorException("ParameterPool::setUniqueMatchValue: pattern '" - + pattern + "' is not unique"); + throw std::runtime_error("ParameterPool::setUniqueMatchValue: pattern '" + pattern + + "' is not unique"); } std::vector<std::string> ParameterPool::parameterNames() const { @@ -195,7 +193,7 @@ void ParameterPool::report_find_matched_parameters_error(const std::string& patt << "' have been found. Existing keys are:" << std::endl; for (const auto* par : m_params) ostr << "'" << par->getName() << "'\n"; - throw Exceptions::RuntimeErrorException(ostr.str()); + throw std::runtime_error(ostr.str()); } //! Reports error while setting parname to given value. @@ -206,7 +204,7 @@ void ParameterPool::report_set_value_error(const std::string& parname, double va ostr << " for parameter '" << parname << "' failed."; ostr << " Parameter limits: '" << parameter(parname)->limits() << "'.\n"; ostr << "Original exception message: " << message << std::endl; - throw Exceptions::RuntimeErrorException(ostr.str()); + throw std::runtime_error(ostr.str()); } size_t ParameterPool::check_index(size_t index) const { diff --git a/Param/Distrib/DistributionHandler.cpp b/Param/Distrib/DistributionHandler.cpp index 6f9e0387499..e31f6313541 100644 --- a/Param/Distrib/DistributionHandler.cpp +++ b/Param/Distrib/DistributionHandler.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Param/Distrib/DistributionHandler.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Distrib/Distributions.h" @@ -37,7 +36,7 @@ size_t DistributionHandler::getTotalNumberOfSamples() const { double DistributionHandler::setParameterValues(ParameterPool* p_parameter_pool, size_t index) { if (index >= m_nbr_combinations) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "DistributionWeighter::setParameterValues: " "index must be smaller than the total number of parameter combinations"); size_t n_distr = m_distributions.size(); @@ -51,9 +50,9 @@ double DistributionHandler::setParameterValues(ParameterPool* p_parameter_pool, m_distributions[param_index].getMainParameterName(), m_cached_samples[param_index][remainder].value); if (changed != 1) { - throw Exceptions::RuntimeErrorException("DistributionWeighter::setParameterValues: " - "parameter name matches nothing or more than " - "one parameter"); + throw std::runtime_error("DistributionWeighter::setParameterValues: " + "parameter name matches nothing or more than " + "one parameter"); } weight *= m_cached_samples[param_index][remainder].weight; if (param_index == 0) diff --git a/Param/Distrib/Distributions.cpp b/Param/Distrib/Distributions.cpp index 395bcd00e43..a480881e6e1 100644 --- a/Param/Distrib/Distributions.cpp +++ b/Param/Distrib/Distributions.cpp @@ -14,7 +14,6 @@ #include "Param/Distrib/Distributions.h" #include "Base/Math/Constants.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Param/Varia/ParameterSample.h" @@ -40,9 +39,8 @@ std::vector<ParameterSample> IDistribution1D::equidistantSamples(size_t nbr_samp double sigma_factor, const RealLimits& limits) const { if (nbr_samples == 0) - throw Exceptions::OutOfBoundsException( - "IDistribution1D::generateSamples: " - "number of generated samples must be bigger than zero"); + throw std::runtime_error("IDistribution1D::generateSamples: " + "number of generated samples must be bigger than zero"); if (isDelta()) return {ParameterSample(getMean())}; return generateSamplesFromValues(equidistantPoints(nbr_samples, sigma_factor, limits)); @@ -53,9 +51,8 @@ std::vector<ParameterSample> IDistribution1D::equidistantSamples(size_t nbr_samp std::vector<ParameterSample> IDistribution1D::equidistantSamplesInRange(size_t nbr_samples, double xmin, double xmax) const { if (nbr_samples == 0) - throw Exceptions::OutOfBoundsException( - "IDistribution1D::generateSamples: " - "number of generated samples must be bigger than zero"); + throw std::runtime_error("IDistribution1D::generateSamples: " + "number of generated samples must be bigger than zero"); if (isDelta()) return {ParameterSample(getMean())}; return generateSamplesFromValues(equidistantPointsInRange(nbr_samples, xmin, xmax)); @@ -88,7 +85,7 @@ void IDistribution1D::adjustMinMaxForLimits(double& xmin, double& xmax, std::ostringstream ostr; ostr << "IDistribution1D::adjustMinMaxForLimits() -> Error. Can't' adjust "; ostr << "xmin:" << xmin << " xmax:" << xmax << " for given limits " << limits << std::endl; - throw Exceptions::DomainErrorException(ostr.str()); + throw std::runtime_error(ostr.str()); } } @@ -104,8 +101,8 @@ IDistribution1D::generateSamplesFromValues(const std::vector<double>& sample_val norm_factor += pdf; } if (norm_factor <= 0.0) - throw Exceptions::RuntimeErrorException("IDistribution1D::generateSamples: " - "total probability must be bigger than zero"); + throw std::runtime_error("IDistribution1D::generateSamples: " + "total probability must be bigger than zero"); for (ParameterSample& sample : result) sample.weight /= norm_factor; return result; @@ -124,7 +121,7 @@ DistributionGate::DistributionGate(const std::vector<double> P) , m_min(m_P[0]) , m_max(m_P[1]) { if (m_max < m_min) - throw Exceptions::ClassInitializationException("DistributionGate: max<min"); + throw std::runtime_error("DistributionGate: max<min"); } DistributionGate::DistributionGate(double min, double max) @@ -165,7 +162,7 @@ DistributionLorentz::DistributionLorentz(const std::vector<double> P) , m_mean(m_P[0]) , m_hwhm(m_P[1]) { if (m_hwhm < 0.0) - throw Exceptions::ClassInitializationException("DistributionLorentz: hwhm<0"); + throw std::runtime_error("DistributionLorentz: hwhm<0"); } DistributionLorentz::DistributionLorentz(double mean, double hwhm) @@ -206,7 +203,7 @@ DistributionGaussian::DistributionGaussian(const std::vector<double> P) , m_mean(m_P[0]) , m_std_dev(m_P[1]) { if (m_std_dev < 0.0) - throw Exceptions::ClassInitializationException("DistributionGaussian: std_dev < 0"); + throw std::runtime_error("DistributionGaussian: std_dev < 0"); } DistributionGaussian::DistributionGaussian(double mean, double std_dev) @@ -248,9 +245,9 @@ DistributionLogNormal::DistributionLogNormal(const std::vector<double> P) , m_median(m_P[0]) , m_scale_param(m_P[1]) { if (m_scale_param < 0.0) - throw Exceptions::ClassInitializationException("DistributionLogNormal: scale_param < 0"); + throw std::runtime_error("DistributionLogNormal: scale_param < 0"); if (m_median <= 0.0) - throw Exceptions::ClassInitializationException("DistributionLogNormal: median < 0"); + throw std::runtime_error("DistributionLogNormal: median < 0"); } DistributionLogNormal::DistributionLogNormal(double median, double scale_param) @@ -308,7 +305,7 @@ DistributionCosine::DistributionCosine(const std::vector<double> P) , m_mean(m_P[0]) , m_sigma(m_P[1]) { if (m_sigma < 0.0) - throw Exceptions::ClassInitializationException("DistributionCosine: sigma<0"); + throw std::runtime_error("DistributionCosine: sigma<0"); } DistributionCosine::DistributionCosine(double mean, double sigma) @@ -355,11 +352,11 @@ DistributionTrapezoid::DistributionTrapezoid(const std::vector<double> P) , m_middle(m_P[2]) , m_right(m_P[3]) { if (m_left < 0.0) - throw Exceptions::ClassInitializationException("DistributionTrapezoid: leftWidth < 0"); + throw std::runtime_error("DistributionTrapezoid: leftWidth < 0"); if (m_middle < 0.0) - throw Exceptions::ClassInitializationException("DistributionTrapezoid: middleWidth < 0"); + throw std::runtime_error("DistributionTrapezoid: middleWidth < 0"); if (m_right < 0.0) - throw Exceptions::ClassInitializationException("DistributionTrapezoid: rightWidth < 0"); + throw std::runtime_error("DistributionTrapezoid: rightWidth < 0"); } DistributionTrapezoid::DistributionTrapezoid(double center, double left, double middle, diff --git a/Param/Distrib/ParameterDistribution.cpp b/Param/Distrib/ParameterDistribution.cpp index dd929e53746..e600e53dda2 100644 --- a/Param/Distrib/ParameterDistribution.cpp +++ b/Param/Distrib/ParameterDistribution.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Param/Distrib/ParameterDistribution.h" -#include "Base/Types/Exceptions.h" #include "Param/Distrib/Distributions.h" ParameterDistribution::ParameterDistribution(const std::string& par_name, @@ -29,13 +28,11 @@ ParameterDistribution::ParameterDistribution(const std::string& par_name, , m_xmax(-1.0) { m_distribution.reset(distribution.clone()); if (m_sigma_factor < 0.0) - throw Exceptions::RuntimeErrorException( - "ParameterDistribution::ParameterDistribution() -> Error." - "sigma factor cannot be negative"); + throw std::runtime_error("ParameterDistribution::ParameterDistribution() -> Error." + "sigma factor cannot be negative"); if (nbr_samples == 0) - throw Exceptions::RuntimeErrorException( - "ParameterDistribution::ParameterDistribution() -> Error." - "Number of samples can't be zero."); + throw std::runtime_error("ParameterDistribution::ParameterDistribution() -> Error." + "Number of samples can't be zero."); } ParameterDistribution::ParameterDistribution(const std::string& par_name, @@ -49,19 +46,16 @@ ParameterDistribution::ParameterDistribution(const std::string& par_name, , m_xmax(xmax) { m_distribution.reset(distribution.clone()); if (m_sigma_factor < 0.0) { - throw Exceptions::RuntimeErrorException( - "ParameterDistribution::ParameterDistribution() -> Error." - "sigma factor cannot be negative"); + throw std::runtime_error("ParameterDistribution::ParameterDistribution() -> Error." + "sigma factor cannot be negative"); } if (nbr_samples == 0) { - throw Exceptions::RuntimeErrorException( - "ParameterDistribution::ParameterDistribution() -> Error." - "Number of samples can't be zero."); + throw std::runtime_error("ParameterDistribution::ParameterDistribution() -> Error." + "Number of samples can't be zero."); } if (xmin >= xmax) { - throw Exceptions::RuntimeErrorException( - "ParameterDistribution::ParameterDistribution() -> Error." - "xmin>=xmax"); + throw std::runtime_error("ParameterDistribution::ParameterDistribution() -> Error." + "xmin>=xmax"); } } diff --git a/Param/Node/NodeUtils.cpp b/Param/Node/NodeUtils.cpp index a62e0d9e22c..a9ec109cc30 100644 --- a/Param/Node/NodeUtils.cpp +++ b/Param/Node/NodeUtils.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Param/Node/NodeUtils.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Param/Node/IterationStrategy.h" @@ -84,8 +83,8 @@ std::string NodeUtils::nodePath(const INode& node, const INode* root) { } if (root != nullptr && current != root) { - throw Exceptions::RuntimeErrorException("NodeUtils::nodePath() -> Error. Node doesn't " - "belong to root's branch"); + throw std::runtime_error("NodeUtils::nodePath() -> Error. Node doesn't " + "belong to root's branch"); } std::reverse(pathElements.begin(), pathElements.end()); diff --git a/Sample/Aggregate/InterferenceFunction1DLattice.cpp b/Sample/Aggregate/InterferenceFunction1DLattice.cpp index 2ef04be2940..e380f702ed6 100644 --- a/Sample/Aggregate/InterferenceFunction1DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunction1DLattice.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Aggregate/InterferenceFunction1DLattice.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Assert.h" #include "Param/Base/RealParameter.h" #include "Sample/Correlations/FTDecay1D.h" diff --git a/Sample/Aggregate/InterferenceFunction2DLattice.cpp b/Sample/Aggregate/InterferenceFunction2DLattice.cpp index eb8ec2fc01b..bd8a0d067cb 100644 --- a/Sample/Aggregate/InterferenceFunction2DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunction2DLattice.cpp @@ -14,7 +14,6 @@ #include "Sample/Aggregate/InterferenceFunction2DLattice.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" #include <algorithm> @@ -80,8 +79,8 @@ void InterferenceFunction2DLattice::onChange() { double InterferenceFunction2DLattice::iff_without_dw(const kvector_t q) const { if (!m_decay) - throw Exceptions::NullPointerException("InterferenceFunction2DLattice::evaluate" - " -> Error! No decay function defined."); + throw std::runtime_error("InterferenceFunction2DLattice::evaluate" + " -> Error! No decay function defined."); m_qx = q.x(); m_qy = q.y(); if (!m_integrate_xi) @@ -107,9 +106,8 @@ double InterferenceFunction2DLattice::interferenceForXi(double xi) const { double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx, double qy) const { if (!m_decay) - throw Exceptions::NullPointerException( - "InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint" - " -> Error! No decay function defined."); + throw std::runtime_error("InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint" + " -> Error! No decay function defined."); double gamma = m_decay->gamma(); auto qXY = rotateOrthonormal(qx, qy, gamma); return m_decay->evaluate(qXY.first, qXY.second); @@ -159,9 +157,8 @@ void InterferenceFunction2DLattice::initialize_rec_vectors() { void InterferenceFunction2DLattice::initialize_calc_factors() { if (!m_decay) - throw Exceptions::NullPointerException( - "InterferenceFunction2DLattice::initialize_calc_factors" - " -> Error! No decay function defined."); + throw std::runtime_error("InterferenceFunction2DLattice::initialize_calc_factors" + " -> Error! No decay function defined."); // number of reciprocal lattice points to use auto q_bounds = m_decay->boundingReciprocalLatticeCoordinates( diff --git a/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp b/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp index 5aa22997a06..eff1a68cb5e 100644 --- a/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp +++ b/Sample/Aggregate/InterferenceFunction2DParaCrystal.cpp @@ -14,7 +14,6 @@ #include "Sample/Aggregate/InterferenceFunction2DParaCrystal.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include <limits> @@ -111,15 +110,13 @@ double InterferenceFunction2DParaCrystal::interferenceForXi(double xi) const { double InterferenceFunction2DParaCrystal::interference1D(double qx, double qy, double xi, size_t index) const { if (index > 1) - throw Exceptions::OutOfBoundsException( - "InterferenceFunction2DParaCrystal::" - "interference1D() -> Error! Index of interference function " - "probability must be < 2"); + throw std::runtime_error("InterferenceFunction2DParaCrystal::" + "interference1D() -> Error! Index of interference function " + "probability must be < 2"); if (!m_pdf1 || !m_pdf2) - throw Exceptions::NullPointerException( - "InterferenceFunction2DParaCrystal::" - "interference1D() -> Error! Probability distributions for " - "interference function not properly initialized"); + throw std::runtime_error("InterferenceFunction2DParaCrystal::" + "interference1D() -> Error! Probability distributions for " + "interference function not properly initialized"); double length = index ? m_lattice->length2() : m_lattice->length1(); int n = static_cast<int>(std::abs(m_domain_sizes[index] / length)); diff --git a/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp b/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp index 727eff9b5d5..8c61e01698e 100644 --- a/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp +++ b/Sample/Aggregate/InterferenceFunction2DSuperLattice.cpp @@ -16,7 +16,6 @@ #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" #include "Sample/Aggregate/InterferenceFunctionNone.h" diff --git a/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp b/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp index 5306dcecb74..59562d7a006 100644 --- a/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunctionFinite2DLattice.cpp @@ -16,7 +16,6 @@ #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" #include <limits> diff --git a/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp b/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp index 269fc462bad..d6a61d70692 100644 --- a/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp +++ b/Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp @@ -15,7 +15,6 @@ #include "Sample/Aggregate/InterferenceFunctionFinite3DLattice.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" #include <limits> diff --git a/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp b/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp index 1119a890974..437661e87f0 100644 --- a/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp +++ b/Sample/Aggregate/InterferenceFunctionRadialParaCrystal.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include <limits> @@ -88,9 +87,9 @@ std::vector<const INode*> InterferenceFunctionRadialParaCrystal::getChildren() c double InterferenceFunctionRadialParaCrystal::iff_without_dw(const kvector_t q) const { if (!m_pdf) - throw Exceptions::NullPointerException("InterferenceFunctionRadialParaCrystal::" - "evaluate() -> Error! Probability distribution for " - "interference function not properly initialized"); + throw std::runtime_error("InterferenceFunctionRadialParaCrystal::" + "evaluate() -> Error! Probability distribution for " + "interference function not properly initialized"); double result = 0.0; double qxr = q.x(); double qyr = q.y(); diff --git a/Sample/Aggregate/ParticleLayout.cpp b/Sample/Aggregate/ParticleLayout.cpp index 3bd52a674ba..664cac9ea39 100644 --- a/Sample/Aggregate/ParticleLayout.cpp +++ b/Sample/Aggregate/ParticleLayout.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Aggregate/ParticleLayout.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Sample/Aggregate/InterferenceFunctionNone.h" diff --git a/Sample/Correlations/FTDistributions1D.cpp b/Sample/Correlations/FTDistributions1D.cpp index 08b2c9c47e7..0df62f6865b 100644 --- a/Sample/Correlations/FTDistributions1D.cpp +++ b/Sample/Correlations/FTDistributions1D.cpp @@ -15,7 +15,6 @@ #include "Sample/Correlations/FTDistributions1D.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -#include "Base/Types/Exceptions.h" #include <limits> namespace { @@ -201,5 +200,5 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DVoigt::createSampler() c std::ostringstream ostr; ostr << "FTDistribution1DVoigt::createSampler() -> Error in class initialization"; ostr << "\n\n Has not been implemented yet...stay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } diff --git a/Sample/Correlations/FTDistributions2D.cpp b/Sample/Correlations/FTDistributions2D.cpp index ba1d270443c..208e7719007 100644 --- a/Sample/Correlations/FTDistributions2D.cpp +++ b/Sample/Correlations/FTDistributions2D.cpp @@ -15,7 +15,6 @@ #include "Sample/Correlations/FTDistributions2D.h" #include "Base/Math/Bessel.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include <limits> // ************************************************************************************************ @@ -165,5 +164,5 @@ std::unique_ptr<IDistribution2DSampler> FTDistribution2DVoigt::createSampler() c std::ostringstream ostr; ostr << "FTDistribution2DVoigt::createSampler() -> Error in class initialization"; ostr << "\n\n Has not been implemented yet...stay tuned!"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } diff --git a/Sample/Fresnel/FormFactorCoherentSum.cpp b/Sample/Fresnel/FormFactorCoherentSum.cpp index 0be1b223b5b..1f899a2a8e3 100644 --- a/Sample/Fresnel/FormFactorCoherentSum.cpp +++ b/Sample/Fresnel/FormFactorCoherentSum.cpp @@ -14,7 +14,6 @@ #include "Sample/Fresnel/FormFactorCoherentSum.h" #include "Base/Pixel/SimulationElement.h" -#include "Base/Types/Exceptions.h" FormFactorCoherentSum::FormFactorCoherentSum(double abundance) : m_abundance(abundance) {} @@ -38,8 +37,8 @@ Eigen::Matrix2cd FormFactorCoherentSum::evaluatePol(const SimulationElement& sim void FormFactorCoherentSum::scaleRelativeAbundance(double total_abundance) { if (total_abundance <= 0.0) - throw Exceptions::LogicErrorException("FormFactorCoherentSum::scaleRelativeAbundance: " - "Trying to scale with non strictly positive factor."); + throw std::runtime_error("FormFactorCoherentSum::scaleRelativeAbundance: " + "Trying to scale with non strictly positive factor."); m_abundance /= total_abundance; } diff --git a/Sample/HardParticle/FormFactorAnisoPyramid.cpp b/Sample/HardParticle/FormFactorAnisoPyramid.cpp index 4081b388463..1b653dafbce 100644 --- a/Sample/HardParticle/FormFactorAnisoPyramid.cpp +++ b/Sample/HardParticle/FormFactorAnisoPyramid.cpp @@ -15,7 +15,6 @@ #include "Sample/HardParticle/FormFactorAnisoPyramid.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -#include "Base/Types/Exceptions.h" const PolyhedralTopology FormFactorAnisoPyramid::topology = {{{{3, 2, 1, 0}, true}, {{0, 1, 5, 4}, false}, @@ -57,7 +56,7 @@ IFormFactor* FormFactorAnisoPyramid::sliceFormFactor(ZLimits limits, const IRota void FormFactorAnisoPyramid::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) - throw Exceptions::OutOfBoundsException("AnisoPyramid: angle alpha out of bounds"); + throw std::runtime_error("AnisoPyramid: angle alpha out of bounds"); double r = cot_alpha * 2 * m_height / m_length; double s = cot_alpha * 2 * m_height / m_width; if (r > 1 || s > 1) { @@ -68,7 +67,7 @@ void FormFactorAnisoPyramid::onChange() { ostr << " height:" << m_height; ostr << " alpha[rad]:" << m_alpha << "\n\n"; ostr << "Check for '2*height <= (length,width)*tan(alpha)' failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } double D = m_length / 2; diff --git a/Sample/HardParticle/FormFactorCantellatedCube.cpp b/Sample/HardParticle/FormFactorCantellatedCube.cpp index 1364302b5e8..e0ceb2fafcd 100644 --- a/Sample/HardParticle/FormFactorCantellatedCube.cpp +++ b/Sample/HardParticle/FormFactorCantellatedCube.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/HardParticle/FormFactorCantellatedCube.h" -#include "Base/Types/Exceptions.h" const PolyhedralTopology FormFactorCantellatedCube::topology = { { @@ -69,7 +68,7 @@ void FormFactorCantellatedCube::onChange() { ostr << "with parameters 'length':" << m_length; ostr << " 'removed_length':" << m_removed_length << "\n\n"; ostr << "Check for removed_length <= 0.5*length failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } double a = m_length / 2; double b = m_removed_length; diff --git a/Sample/HardParticle/FormFactorCone.cpp b/Sample/HardParticle/FormFactorCone.cpp index 2ff6a874e2e..2e13ab61bba 100644 --- a/Sample/HardParticle/FormFactorCone.cpp +++ b/Sample/HardParticle/FormFactorCone.cpp @@ -17,7 +17,6 @@ #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include "Sample/Shapes/DoubleEllipse.h" #include <limits> @@ -33,7 +32,7 @@ FormFactorCone::FormFactorCone(const std::vector<double> P) , m_alpha(m_P[2]) { m_cot_alpha = Math::cot(m_alpha); if (!std::isfinite(m_cot_alpha) || m_cot_alpha < 0) - throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); + throw std::runtime_error("pyramid angle alpha out of bounds"); if (m_cot_alpha * m_height > m_radius) { std::ostringstream ostr; ostr << "FormFactorCone() -> Error in class initialization "; @@ -41,7 +40,7 @@ FormFactorCone::FormFactorCone(const std::vector<double> P) ostr << " m_height:" << m_height; ostr << " alpha[rad]:" << m_alpha << "\n\n"; ostr << "Check for 'height <= radius*tan(alpha)' failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } onChange(); } diff --git a/Sample/HardParticle/FormFactorCone6.cpp b/Sample/HardParticle/FormFactorCone6.cpp index bb17ab17fd6..959849551f1 100644 --- a/Sample/HardParticle/FormFactorCone6.cpp +++ b/Sample/HardParticle/FormFactorCone6.cpp @@ -15,7 +15,6 @@ #include "Sample/HardParticle/FormFactorCone6.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -#include "Base/Types/Exceptions.h" const PolyhedralTopology FormFactorCone6::topology = {{{{5, 4, 3, 2, 1, 0}, true}, {{0, 1, 7, 6}, false}, @@ -56,7 +55,7 @@ IFormFactor* FormFactorCone6::sliceFormFactor(ZLimits limits, const IRotation& r void FormFactorCone6::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) - throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); + throw std::runtime_error("pyramid angle alpha out of bounds"); double r = cot_alpha * 2 / sqrt(3) * m_height / m_base_edge; // L(top)/L(base) if (r > 1) { std::ostringstream ostr; @@ -64,7 +63,7 @@ void FormFactorCone6::onChange() { ostr << "(base_edge=" << m_base_edge; ostr << ", height:" << m_height; ostr << ", alpha[rad]:" << m_alpha << ")"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } double a = m_base_edge; diff --git a/Sample/HardParticle/FormFactorCuboctahedron.cpp b/Sample/HardParticle/FormFactorCuboctahedron.cpp index 0dbf65df380..16a329e7ca5 100644 --- a/Sample/HardParticle/FormFactorCuboctahedron.cpp +++ b/Sample/HardParticle/FormFactorCuboctahedron.cpp @@ -15,7 +15,6 @@ #include "Sample/HardParticle/FormFactorCuboctahedron.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -#include "Base/Types/Exceptions.h" #include "Sample/HardParticle/FormFactorPyramid.h" const PolyhedralTopology FormFactorCuboctahedron::topology = {{{{3, 2, 1, 0}, true}, @@ -75,7 +74,7 @@ IFormFactor* FormFactorCuboctahedron::sliceFormFactor(ZLimits limits, const IRot void FormFactorCuboctahedron::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) - throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); + throw std::runtime_error("pyramid angle alpha out of bounds"); double x = m_height_ratio; double r = cot_alpha * 2 * m_height / m_length; if (std::max(1., x) * r > 1) { @@ -86,7 +85,7 @@ void FormFactorCuboctahedron::onChange() { ostr << " height_ratio:" << m_height_ratio; ostr << " alpha[rad]:" << m_alpha << "\n\n"; ostr << "Check for '2.*height <= length*tan(alpha)*min(1.,1.0/height_ratio)' failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } double a = m_length / 2 * (1 - r); diff --git a/Sample/HardParticle/FormFactorHollowSphere.cpp b/Sample/HardParticle/FormFactorHollowSphere.cpp index df8894bb9c9..b8de362a7fc 100644 --- a/Sample/HardParticle/FormFactorHollowSphere.cpp +++ b/Sample/HardParticle/FormFactorHollowSphere.cpp @@ -14,7 +14,6 @@ #include "Sample/HardParticle/FormFactorHollowSphere.h" #include "Base/Math/Constants.h" -#include "Base/Types/Exceptions.h" #include "Sample/Shapes/TruncatedEllipsoid.h" #include <limits> @@ -27,9 +26,8 @@ FormFactorHollowSphere::FormFactorHollowSphere(const std::vector<double> P) , m_mean(m_P[0]) , m_full_width(m_P[1]) { if (!checkParameters()) - throw Exceptions::ClassInitializationException( - "FormFactorHollowSphere::FormFactorHollowSphere:" - " mean radius must be bigger than the half width"); + throw std::runtime_error("FormFactorHollowSphere::FormFactorHollowSphere:" + " mean radius must be bigger than the half width"); onChange(); } diff --git a/Sample/HardParticle/FormFactorPyramid.cpp b/Sample/HardParticle/FormFactorPyramid.cpp index febf03f9a3b..c87aff72685 100644 --- a/Sample/HardParticle/FormFactorPyramid.cpp +++ b/Sample/HardParticle/FormFactorPyramid.cpp @@ -15,7 +15,6 @@ #include "Sample/HardParticle/FormFactorPyramid.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -#include "Base/Types/Exceptions.h" const PolyhedralTopology FormFactorPyramid::topology = {{ {{3, 2, 1, 0}, true}, // TODO -> true @@ -55,7 +54,7 @@ IFormFactor* FormFactorPyramid::sliceFormFactor(ZLimits limits, const IRotation& void FormFactorPyramid::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha)) - throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); + throw std::runtime_error("pyramid angle alpha out of bounds"); double r = cot_alpha * 2 * m_height / m_base_edge; // [L(base)-L(top)]/L(base) if (r > 1) { std::ostringstream ostr; @@ -64,7 +63,7 @@ void FormFactorPyramid::onChange() { ostr << " height:" << m_height; ostr << " alpha[rad]:" << m_alpha << "\n\n"; ostr << "Check for 'height <= base_edge*tan(alpha)' failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } double a = m_base_edge / 2; diff --git a/Sample/HardParticle/FormFactorTetrahedron.cpp b/Sample/HardParticle/FormFactorTetrahedron.cpp index 030e4bb0d6f..eb688ebdda7 100644 --- a/Sample/HardParticle/FormFactorTetrahedron.cpp +++ b/Sample/HardParticle/FormFactorTetrahedron.cpp @@ -15,7 +15,6 @@ #include "Sample/HardParticle/FormFactorTetrahedron.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" -#include "Base/Types/Exceptions.h" const PolyhedralTopology FormFactorTetrahedron::topology = {{{{2, 1, 0}, false}, {{0, 1, 4, 3}, false}, @@ -53,7 +52,7 @@ IFormFactor* FormFactorTetrahedron::sliceFormFactor(ZLimits limits, const IRotat void FormFactorTetrahedron::onChange() { double cot_alpha = Math::cot(m_alpha); if (!std::isfinite(cot_alpha) || cot_alpha < 0) - throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds"); + throw std::runtime_error("pyramid angle alpha out of bounds"); double r = cot_alpha * 2 * std::sqrt(3.) * m_height / m_base_edge; // L(top)/L(base) if (r > 1) { std::ostringstream ostr; @@ -61,7 +60,7 @@ void FormFactorTetrahedron::onChange() { ostr << "(base_edge=" << m_base_edge; ostr << ", height:" << m_height; ostr << ", alpha[rad]:" << m_alpha << ")"; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } double a = m_base_edge; diff --git a/Sample/HardParticle/FormFactorTruncatedCube.cpp b/Sample/HardParticle/FormFactorTruncatedCube.cpp index 7d55bd80d35..ec5e79f5941 100644 --- a/Sample/HardParticle/FormFactorTruncatedCube.cpp +++ b/Sample/HardParticle/FormFactorTruncatedCube.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/HardParticle/FormFactorTruncatedCube.h" -#include "Base/Types/Exceptions.h" const PolyhedralTopology FormFactorTruncatedCube::topology = { {{{0, 1, 7, 6, 9, 10, 4, 3}, true}, @@ -54,7 +53,7 @@ void FormFactorTruncatedCube::onChange() { ostr << "with parameters 'length':" << m_length; ostr << " 'removed_length':" << m_removed_length << "\n\n"; ostr << "Check for removed_length <= 0.5*length failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } double a = m_length / 2; diff --git a/Sample/HardParticle/FormFactorTruncatedSphere.cpp b/Sample/HardParticle/FormFactorTruncatedSphere.cpp index 0d8033c7e38..fde3f33a880 100644 --- a/Sample/HardParticle/FormFactorTruncatedSphere.cpp +++ b/Sample/HardParticle/FormFactorTruncatedSphere.cpp @@ -16,7 +16,6 @@ #include "Base/Math/Bessel.h" #include "Base/Math/Constants.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include "Sample/Shapes/TruncatedEllipsoid.h" #include <limits> @@ -45,7 +44,7 @@ bool FormFactorTruncatedSphere::check_initialization() const { ostr << "with parameters 'radius':" << m_radius << " 'height':" << m_height << " 'delta_height':" << m_dh << "\n\n"; ostr << "Check for height <= 2.*radius AND delta_height < height failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } return result; } diff --git a/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp b/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp index d6627d3f732..98f8244b554 100644 --- a/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp +++ b/Sample/HardParticle/FormFactorTruncatedSpheroid.cpp @@ -16,7 +16,6 @@ #include "Base/Math/Bessel.h" #include "Base/Math/Constants.h" #include "Base/Math/Integrator.h" -#include "Base/Types/Exceptions.h" #include "Sample/Shapes/TruncatedEllipsoid.h" #include <limits> @@ -49,7 +48,7 @@ bool FormFactorTruncatedSpheroid::check_initialization() const { ostr << " height:" << m_height; ostr << " height_flattening:" << m_height_flattening << "\n\n"; ostr << "Check for 'height <= 2.*radius*height_flattening' failed."; - throw Exceptions::ClassInitializationException(ostr.str()); + throw std::runtime_error(ostr.str()); } return result; } diff --git a/Sample/Interference/DecouplingApproximationStrategy.cpp b/Sample/Interference/DecouplingApproximationStrategy.cpp index 6d3200eb141..9418dd3c70e 100644 --- a/Sample/Interference/DecouplingApproximationStrategy.cpp +++ b/Sample/Interference/DecouplingApproximationStrategy.cpp @@ -15,7 +15,6 @@ #include "Sample/Interference/DecouplingApproximationStrategy.h" #include "Base/Math/Functions.h" #include "Base/Pixel/SimulationElement.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" #include "Sample/Aggregate/InterferenceFunctionNone.h" #include "Sample/Fresnel/FormFactorCoherentSum.h" @@ -38,7 +37,7 @@ DecouplingApproximationStrategy::scalarCalculation(const SimulationElement& sim_ for (const auto& ffw : m_weighted_formfactors) { const complex_t ff = ffw.evaluate(sim_element); if (std::isnan(ff.real())) - throw Exceptions::RuntimeErrorException( + throw std::runtime_error( "DecouplingApproximationStrategy::scalarCalculation() -> Error! Amplitude is NaN"); double fraction = ffw.relativeAbundance(); amplitude += fraction * ff; @@ -59,9 +58,8 @@ DecouplingApproximationStrategy::polarizedCalculation(const SimulationElement& s for (const auto& ffw : m_weighted_formfactors) { const Eigen::Matrix2cd ff = ffw.evaluatePol(sim_element); if (!ff.allFinite()) - throw Exceptions::RuntimeErrorException( - "DecouplingApproximationStrategy::polarizedCalculation() -> " - "Error! Form factor contains NaN or infinite"); + throw std::runtime_error("DecouplingApproximationStrategy::polarizedCalculation() -> " + "Error! Form factor contains NaN or infinite"); const double fraction = ffw.relativeAbundance(); mean_amplitude += fraction * ff; mean_intensity += fraction * (ff * polarization_handler.getPolarization() * ff.adjoint()); diff --git a/Sample/Interference/IInterferenceFunctionStrategy.cpp b/Sample/Interference/IInterferenceFunctionStrategy.cpp index e88799e0614..df48316ed5b 100644 --- a/Sample/Interference/IInterferenceFunctionStrategy.cpp +++ b/Sample/Interference/IInterferenceFunctionStrategy.cpp @@ -15,7 +15,6 @@ #include "Sample/Interference/IInterferenceFunctionStrategy.h" #include "Base/Math/IntegratorMCMiser.h" #include "Base/Pixel/SimulationElement.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Assert.h" #include "Sample/Fresnel/FormFactorCoherentSum.h" diff --git a/Sample/Interference/SSCApproximationStrategy.cpp b/Sample/Interference/SSCApproximationStrategy.cpp index 08865ac5217..bb1cdb30a1f 100644 --- a/Sample/Interference/SSCApproximationStrategy.cpp +++ b/Sample/Interference/SSCApproximationStrategy.cpp @@ -14,7 +14,6 @@ #include "Sample/Interference/SSCApproximationStrategy.h" #include "Base/Pixel/SimulationElement.h" -#include "Base/Types/Exceptions.h" #include "Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h" #include "Sample/Fresnel/FormFactorCoherentSum.h" diff --git a/Sample/Material/Material.cpp b/Sample/Material/Material.cpp index 96aef5472e3..900106cab3a 100644 --- a/Sample/Material/Material.cpp +++ b/Sample/Material/Material.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Material/Material.h" -#include "Base/Types/Exceptions.h" #include "Base/Vector/Transform3D.h" #include "Sample/Material/WavevectorInfo.h" #include <typeinfo> @@ -23,15 +22,13 @@ Material::Material(std::unique_ptr<BaseMaterialImpl> material_impl) Material::Material(const Material& material) { if (material.isEmpty()) - throw Exceptions::NullPointerException( - "Material: Error! Attempt to initialize material with nullptr."); + throw std::runtime_error("Material: Error! Attempt to initialize material with nullptr."); m_material_impl.reset(material.m_material_impl->clone()); } Material& Material::operator=(const Material& other) { if (other.isEmpty()) - throw Exceptions::NullPointerException( - "Material: Error! Attempt to assign nullptr to material."); + throw std::runtime_error("Material: Error! Attempt to assign nullptr to material."); m_material_impl.reset(other.m_material_impl->clone()); return *this; } diff --git a/Sample/Multilayer/Layer.cpp b/Sample/Multilayer/Layer.cpp index 111901edb6b..b4ec21466ab 100644 --- a/Sample/Multilayer/Layer.cpp +++ b/Sample/Multilayer/Layer.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Multilayer/Layer.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Sample/Aggregate/ParticleLayout.h" @@ -42,7 +41,7 @@ Layer* Layer::clone() const { //! Sets layer thickness in nanometers. void Layer::setThickness(double thickness) { if (thickness < 0.) - throw Exceptions::DomainErrorException("Layer thickness cannot be negative"); + throw std::runtime_error("Layer thickness cannot be negative"); m_thickness = thickness; } diff --git a/Sample/Multilayer/MultiLayer.cpp b/Sample/Multilayer/MultiLayer.cpp index 1e4d2711c27..a678bb5c19b 100644 --- a/Sample/Multilayer/MultiLayer.cpp +++ b/Sample/Multilayer/MultiLayer.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Multilayer/MultiLayer.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Sample/Aggregate/ParticleLayout.h" @@ -91,7 +90,7 @@ const LayerInterface* MultiLayer::layerInterface(size_t i_interface) const { void MultiLayer::setCrossCorrLength(double crossCorrLength) { if (crossCorrLength < 0.0) - throw Exceptions::LogicErrorException("Attempt to set crossCorrLength to negative value"); + throw std::runtime_error("Attempt to set crossCorrLength to negative value"); m_crossCorrLength = crossCorrLength; } @@ -136,12 +135,12 @@ void MultiLayer::handleLayerThicknessRegistration() { size_t MultiLayer::check_layer_index(size_t i_layer) const { if (i_layer >= m_layers.size()) - throw Exceptions::OutOfBoundsException("Layer index is out of bounds"); + throw std::runtime_error("Layer index is out of bounds"); return i_layer; } size_t MultiLayer::check_interface_index(size_t i_interface) const { if (i_interface >= m_interfaces.size()) - throw Exceptions::OutOfBoundsException("Interface index is out of bounds"); + throw std::runtime_error("Interface index is out of bounds"); return i_interface; } diff --git a/Sample/Particle/FormFactorCrystal.cpp b/Sample/Particle/FormFactorCrystal.cpp index dcea5c98dff..b0d9edc0a1b 100644 --- a/Sample/Particle/FormFactorCrystal.cpp +++ b/Sample/Particle/FormFactorCrystal.cpp @@ -14,7 +14,6 @@ #include "Sample/Particle/FormFactorCrystal.h" #include "Base/Math/Constants.h" -#include "Base/Types/Exceptions.h" #include "Sample/Material/WavevectorInfo.h" FormFactorCrystal::FormFactorCrystal(const Lattice3D& lattice, const IFormFactor& basis_form_factor, diff --git a/Sample/Particle/ParticleComposition.cpp b/Sample/Particle/ParticleComposition.cpp index f8feb238334..25ad730208e 100644 --- a/Sample/Particle/ParticleComposition.cpp +++ b/Sample/Particle/ParticleComposition.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Particle/ParticleComposition.h" -#include "Base/Types/Exceptions.h" #include "Sample/Particle/FormFactorWeighted.h" #include "Sample/Particle/ParticleDistribution.h" #include "Sample/Scattering/Rotations.h" @@ -109,7 +108,7 @@ ParticleLimits ParticleComposition::bottomTopZ() const { size_t ParticleComposition::check_index(size_t index) const { return index < m_particles.size() ? index - : throw Exceptions::OutOfBoundsException( + : throw std::runtime_error( "ParticleComposition::check_index() -> Index is out of bounds"); } diff --git a/Sample/Particle/ParticleDistribution.cpp b/Sample/Particle/ParticleDistribution.cpp index 26b79a8fae3..76c4b7bb6fd 100644 --- a/Sample/Particle/ParticleDistribution.cpp +++ b/Sample/Particle/ParticleDistribution.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Particle/ParticleDistribution.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Param/Distrib/Distributions.h" diff --git a/Sample/RT/ILayerRTCoefficients.h b/Sample/RT/ILayerRTCoefficients.h index 694778e2d96..e3896fb9a9f 100644 --- a/Sample/RT/ILayerRTCoefficients.h +++ b/Sample/RT/ILayerRTCoefficients.h @@ -16,7 +16,6 @@ #define BORNAGAIN_SAMPLE_RT_ILAYERRTCOEFFICIENTS_H #include "Base/Types/Complex.h" -#include "Base/Types/Exceptions.h" #include "Base/Vector/EigenCore.h" //! Interface to access reflection/transmission coefficients. @@ -45,20 +44,20 @@ public: //! be used when the derived object is really scalar #endif virtual complex_t getScalarT() const { - throw Exceptions::NotImplementedException("ILayerRTCoefficients::" - "getScalarT(): coefficients are not scalar."); + throw std::runtime_error("ILayerRTCoefficients::" + "getScalarT(): coefficients are not scalar."); } virtual complex_t getScalarR() const { - throw Exceptions::NotImplementedException("ILayerRTCoefficients::" - "getScalarR(): coefficients are not scalar."); + throw std::runtime_error("ILayerRTCoefficients::" + "getScalarR(): coefficients are not scalar."); } virtual complex_t getScalarKz() const { - throw Exceptions::NotImplementedException("ILayerRTCoefficients::" - "getScalarKz(): coefficients are not scalar."); + throw std::runtime_error("ILayerRTCoefficients::" + "getScalarKz(): coefficients are not scalar."); } virtual Eigen::Matrix2cd getReflectionMatrix() const { - throw Exceptions::NotImplementedException("Only defined for Matrix coefficeints"); + throw std::runtime_error("Only defined for Matrix coefficeints"); } }; diff --git a/Sample/Scattering/IBornFF.cpp b/Sample/Scattering/IBornFF.cpp index 79cb7cc1e60..c4f30394d3d 100644 --- a/Sample/Scattering/IBornFF.cpp +++ b/Sample/Scattering/IBornFF.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Scattering/IBornFF.h" -#include "Base/Types/Exceptions.h" #include "Base/Utils/Algorithms.h" #include "Sample/Material/WavevectorInfo.h" #include "Sample/Scattering/Rotations.h" diff --git a/Sample/Scattering/ISample.cpp b/Sample/Scattering/ISample.cpp index 80732eeee4d..81a7581b7e0 100644 --- a/Sample/Scattering/ISample.cpp +++ b/Sample/Scattering/ISample.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Scattering/ISample.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Sample/Material/Material.h" #include <algorithm> diff --git a/Sample/Slice/LayerInterface.cpp b/Sample/Slice/LayerInterface.cpp index 07d961b88f0..d0310c5b223 100644 --- a/Sample/Slice/LayerInterface.cpp +++ b/Sample/Slice/LayerInterface.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "Sample/Slice/LayerInterface.h" -#include "Base/Types/Exceptions.h" #include "Sample/Slice/LayerRoughness.h" LayerInterface::LayerInterface() : m_topLayer(nullptr), m_bottomLayer(nullptr) { @@ -23,7 +22,7 @@ LayerInterface::LayerInterface() : m_topLayer(nullptr), m_bottomLayer(nullptr) { LayerInterface::~LayerInterface() = default; LayerInterface* LayerInterface::clone() const { - throw Exceptions::NotImplementedException("LayerInterface::clone() -> Not allowed to clone."); + throw std::runtime_error("LayerInterface::clone() -> Not allowed to clone."); } LayerInterface* LayerInterface::createSmoothInterface(const Layer* top_layer, @@ -54,8 +53,8 @@ std::vector<const INode*> LayerInterface::getChildren() const { void LayerInterface::setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer) { if (top_layer == nullptr || bottom_layer == nullptr) - throw Exceptions::RuntimeErrorException("LayerInterface::setLayersTopBottom() -> Error. " - "Attempt to set nullptr."); + throw std::runtime_error("LayerInterface::setLayersTopBottom() -> Error. " + "Attempt to set nullptr."); m_topLayer = top_layer; m_bottomLayer = bottom_layer; } diff --git a/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp b/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp index 331f86ee806..f26ccc155ef 100644 --- a/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp +++ b/Tests/UnitTests/Core/Axes/FixedBinAxisTest.cpp @@ -1,5 +1,4 @@ #include "Base/Axis/FixedBinAxis.h" -#include "Base/Types/Exceptions.h" #include "Device/InputOutput/DataFormatUtils.h" #include "Tests/GTestWrapper/google_test.h" #include <iostream> @@ -20,7 +19,7 @@ TEST_F(FixedBinAxisTest, IndexedAccessor) { EXPECT_DOUBLE_EQ(-1.0, a2[0]); EXPECT_DOUBLE_EQ(0.0, a2[1]); EXPECT_DOUBLE_EQ(1.0, a2[2]); - ASSERT_THROW(a2[3], Exceptions::OutOfBoundsException); + ASSERT_THROW(a2[3], std::runtime_error); } TEST_F(FixedBinAxisTest, VectorOfUnitLength) { @@ -38,7 +37,7 @@ TEST_F(FixedBinAxisTest, FindClosestIndex) { EXPECT_EQ(size_t(0), v1.findClosestIndex(0.25)); EXPECT_EQ(size_t(1), v1.findClosestIndex(0.5)); EXPECT_EQ(size_t(1), v1.findClosestIndex(0.6)); - // ASSERT_THROW( v1.findClosestIndex(1.0), Exceptions::OutOfBoundsException); + // ASSERT_THROW( v1.findClosestIndex(1.0), std::runtime_error); EXPECT_EQ(size_t(1), v1.findClosestIndex(1.0)); FixedBinAxis v2("name", 3, -1.5, 1.5); @@ -48,7 +47,7 @@ TEST_F(FixedBinAxisTest, FindClosestIndex) { EXPECT_EQ(size_t(1), v2.findClosestIndex(0.0)); EXPECT_EQ(size_t(2), v2.findClosestIndex(0.5)); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.499)); - // ASSERT_THROW( v2.findClosestIndex(1.5), Exceptions::OutOfBoundsException); + // ASSERT_THROW( v2.findClosestIndex(1.5), std::runtime_error); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.5)); } @@ -77,7 +76,7 @@ TEST_F(FixedBinAxisTest, CheckBin) { EXPECT_DOUBLE_EQ(9.5, bin19.m_lower); EXPECT_DOUBLE_EQ(10.0, bin19.m_upper); - ASSERT_THROW(axis.bin(20), Exceptions::OutOfBoundsException); + ASSERT_THROW(axis.bin(20), std::runtime_error); FixedBinAxis axis2("name", 3, -1, 2.0); EXPECT_DOUBLE_EQ(-0.5, axis2.bin(0).center()); diff --git a/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp b/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp index 7527ee5c110..9a7ba52d8ad 100644 --- a/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp +++ b/Tests/UnitTests/Core/Axes/Histogram1DTest.cpp @@ -11,7 +11,7 @@ TEST_F(Histogram1DTest, FixedBinConstructor) { EXPECT_EQ(size_t(5), hist.getTotalNumberOfBins()); EXPECT_EQ(0.0, hist.getXmin()); EXPECT_EQ(5.0, hist.getXmax()); - EXPECT_THROW(hist.yAxis(), Exceptions::LogicErrorException); + EXPECT_THROW(hist.yAxis(), std::runtime_error); for (size_t index = 0; index < hist.getTotalNumberOfBins(); ++index) { EXPECT_EQ(index, hist.getGlobalBin(index)); EXPECT_EQ(index, hist.xAxisIndex(index)); diff --git a/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp b/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp index 54f2a966680..1d128a35b7e 100644 --- a/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp +++ b/Tests/UnitTests/Core/Axes/VariableBinAxisTest.cpp @@ -1,5 +1,4 @@ #include "Base/Axis/VariableBinAxis.h" -#include "Base/Types/Exceptions.h" #include "Device/InputOutput/DataFormatUtils.h" #include "Tests/GTestWrapper/google_test.h" @@ -17,17 +16,17 @@ TEST_F(VariableBinAxisTest, VectorOfUnitLength) { TEST_F(VariableBinAxisTest, ValidityOfCOnstructor) { std::vector<double> values; - ASSERT_THROW(VariableBinAxis("name", 1, values), Exceptions::LogicErrorException); + ASSERT_THROW(VariableBinAxis("name", 1, values), std::runtime_error); values.resize(5); - ASSERT_THROW(VariableBinAxis("name", 5, values), Exceptions::LogicErrorException); + ASSERT_THROW(VariableBinAxis("name", 5, values), std::runtime_error); static const double arr1[] = {-1.5, -1.5, 0.5, 1.5}; std::vector<double> v1(arr1, arr1 + sizeof(arr1) / sizeof(arr1[0])); - ASSERT_THROW(VariableBinAxis("name", 3, v1), Exceptions::LogicErrorException); + ASSERT_THROW(VariableBinAxis("name", 3, v1), std::runtime_error); static const double arr2[] = {1.5, -0.5, 0.5, -1.5}; std::vector<double> v2(arr2, arr2 + sizeof(arr2) / sizeof(arr2[0])); - ASSERT_THROW(VariableBinAxis("name", 3, v2), Exceptions::LogicErrorException); + ASSERT_THROW(VariableBinAxis("name", 3, v2), std::runtime_error); } TEST_F(VariableBinAxisTest, IndexedAccessor) { @@ -57,7 +56,7 @@ TEST_F(VariableBinAxisTest, IndexedAccessor) { EXPECT_DOUBLE_EQ(-1.0, a2[0]); EXPECT_DOUBLE_EQ(0.0, a2[1]); EXPECT_DOUBLE_EQ(1.0, a2[2]); - ASSERT_THROW(a2[3], Exceptions::OutOfBoundsException); + ASSERT_THROW(a2[3], std::runtime_error); } TEST_F(VariableBinAxisTest, FindClosestIndex) { @@ -70,7 +69,7 @@ TEST_F(VariableBinAxisTest, FindClosestIndex) { EXPECT_EQ(size_t(0), v1.findClosestIndex(0.25)); EXPECT_EQ(size_t(1), v1.findClosestIndex(0.5)); EXPECT_EQ(size_t(1), v1.findClosestIndex(0.6)); - // ASSERT_THROW( v1.findClosestIndex(1.0), Exceptions::OutOfBoundsException); + // ASSERT_THROW( v1.findClosestIndex(1.0), std::runtime_error); EXPECT_EQ(size_t(1), v1.findClosestIndex(1.0)); static const double arr2[] = {-1.5, -0.5, 0.5, 1.5}; @@ -82,7 +81,7 @@ TEST_F(VariableBinAxisTest, FindClosestIndex) { EXPECT_EQ(size_t(1), v2.findClosestIndex(0.0)); EXPECT_EQ(size_t(2), v2.findClosestIndex(0.5)); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.499)); - // ASSERT_THROW( v2.findClosestIndex(1.5), Exceptions::OutOfBoundsException); + // ASSERT_THROW( v2.findClosestIndex(1.5), std::runtime_error); EXPECT_EQ(size_t(2), v2.findClosestIndex(1.5)); static const double arr3[] = {-1.0, -0.5, 0.5, 1.0, 2.0}; diff --git a/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp b/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp index f675e6ab002..23432bfd51e 100644 --- a/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp +++ b/Tests/UnitTests/Core/DataStructure/LLDataTest.cpp @@ -160,7 +160,7 @@ TEST_F(LLDataTest, Addition) { LLData<float>* fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) += (*fl_data_1d2), Exceptions::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) += (*fl_data_1d2), std::runtime_error); LLData<Eigen::Matrix2d>* other_matrix_data_2d = new LLData<Eigen::Matrix2d>(*matrix_data_2d); matrix_data_2d->setAll(Eigen::Matrix2d::Identity()); @@ -198,7 +198,7 @@ TEST_F(LLDataTest, Substraction) { LLData<float>* fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) -= (*fl_data_1d2), Exceptions::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) -= (*fl_data_1d2), std::runtime_error); LLData<Eigen::Matrix2d>* other_matrix_data_2d = new LLData<Eigen::Matrix2d>(*matrix_data_2d); matrix_data_2d->setAll(Eigen::Matrix2d::Identity()); @@ -235,7 +235,7 @@ TEST_F(LLDataTest, Multiplication) { LLData<float>* fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) *= (*fl_data_1d2), Exceptions::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) *= (*fl_data_1d2), std::runtime_error); LLData<Eigen::Matrix2d>* other_matrix_data_2d = new LLData<Eigen::Matrix2d>(*matrix_data_2d); matrix_data_2d->setAll(2 * Eigen::Matrix2d::Identity()); @@ -272,7 +272,7 @@ TEST_F(LLDataTest, Division) { LLData<float>* fl_data_1d2 = new LLData<float>(1u, odim1); fl_data_1d2->setAll(10.0); - EXPECT_THROW((*fl_data_1d) /= (*fl_data_1d2), Exceptions::RuntimeErrorException); + EXPECT_THROW((*fl_data_1d) /= (*fl_data_1d2), std::runtime_error); delete fl_data_1d2; delete[] odim1; diff --git a/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp b/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp index 95a89252aac..e4ca458b924 100644 --- a/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp +++ b/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp @@ -260,7 +260,7 @@ TEST_F(RectangularDetectorTest, AnalyzerProperties) { // if direction is the zero vector, an exception is thrown EXPECT_THROW(detector.setAnalyzerProperties(direction, efficiency, total_transmission), - Exceptions::ClassInitializationException); + std::runtime_error); // zero efficiency direction = kvector_t(1.0, 0.0, 0.0); diff --git a/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp b/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp index 0735b45dd62..88f509c4527 100644 --- a/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp +++ b/Tests/UnitTests/Core/Detector/RegionOfInterestTest.cpp @@ -30,7 +30,7 @@ TEST_F(RegionOfInterestTest, constructor) { EXPECT_EQ(roi.roiIndex(9), 2u); EXPECT_EQ(roi.roiIndex(21), 8u); EXPECT_EQ(roi.roiIndex(22), 9u); - EXPECT_THROW(roi.roiIndex(23), Exceptions::RuntimeErrorException); + EXPECT_THROW(roi.roiIndex(23), std::runtime_error); // converting local ro index to global detector index EXPECT_EQ(roi.detectorIndex(0), 5u); @@ -93,7 +93,7 @@ TEST_F(RegionOfInterestTest, clone) { EXPECT_EQ(clone->roiIndex(9), 2u); EXPECT_EQ(clone->roiIndex(21), 8u); EXPECT_EQ(clone->roiIndex(22), 9u); - EXPECT_THROW(clone->roiIndex(23), Exceptions::RuntimeErrorException); + EXPECT_THROW(clone->roiIndex(23), std::runtime_error); // converting local ro index to global detector index EXPECT_EQ(clone->detectorIndex(0), 5u); diff --git a/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp b/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp index 16abd26e79c..c01f6fa780b 100644 --- a/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp +++ b/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp @@ -221,7 +221,7 @@ TEST_F(SphericalDetectorTest, AnalyzerProperties) { // if direction is the zero vector, an exception is thrown EXPECT_THROW(detector.setAnalyzerProperties(direction, efficiency, total_transmission), - Exceptions::ClassInitializationException); + std::runtime_error); // zero efficiency direction = kvector_t(1.0, 0.0, 0.0); diff --git a/Tests/UnitTests/Core/Other/MaterialTest.cpp b/Tests/UnitTests/Core/Other/MaterialTest.cpp index fd27aeb3789..51048ec42ee 100644 --- a/Tests/UnitTests/Core/Other/MaterialTest.cpp +++ b/Tests/UnitTests/Core/Other/MaterialTest.cpp @@ -1,5 +1,4 @@ #include "Base/Const/Units.h" -#include "Base/Types/Exceptions.h" #include "Base/Vector/Transform3D.h" #include "Sample/Material/MaterialBySLDImpl.h" #include "Sample/Material/RefractiveMaterialImpl.h" diff --git a/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp b/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp index a04db0f30dc..d08f92f3e94 100644 --- a/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp +++ b/Tests/UnitTests/Core/Parameters/DistributionsTest.cpp @@ -1,6 +1,5 @@ #include "Param/Distrib/Distributions.h" #include "Base/Math/Constants.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" #include "Param/Varia/ParameterSample.h" #include "Tests/GTestWrapper/google_test.h" @@ -29,7 +28,7 @@ TEST_F(DistributionsTest, DistributionGateDefaultConstructor) { TEST_F(DistributionsTest, DistributionGateConstructor) { // Throw error when m_min > m_max: - EXPECT_THROW(DistributionGate(1.1, 1.0), Exceptions::ClassInitializationException); + EXPECT_THROW(DistributionGate(1.1, 1.0), std::runtime_error); // When m_min == m_max, only one sample is generated (the mean): DistributionGate distr1(1.0, 1.0); diff --git a/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp b/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp index afe6941162d..0b9c6bf21f0 100644 --- a/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp +++ b/Tests/UnitTests/Core/Parameters/ParameterDistributionTest.cpp @@ -1,5 +1,4 @@ #include "Param/Distrib/ParameterDistribution.h" -#include "Base/Types/Exceptions.h" #include "Param/Distrib/Distributions.h" #include "Param/Varia/ParameterUtils.h" #include "Tests/GTestWrapper/google_test.h" @@ -10,9 +9,8 @@ class ParameterDistributionTest : public ::testing::Test {}; TEST_F(ParameterDistributionTest, ParameterDistributionConstructor) { std::string name = "MainParameterName"; DistributionGate distribution(1.0, 2.0); - EXPECT_THROW(ParameterDistribution(name, distribution, 1, -1.0), - Exceptions::RuntimeErrorException); - EXPECT_THROW(ParameterDistribution(name, distribution, 0), Exceptions::RuntimeErrorException); + EXPECT_THROW(ParameterDistribution(name, distribution, 1, -1.0), std::runtime_error); + EXPECT_THROW(ParameterDistribution(name, distribution, 0), std::runtime_error); // Sigma constructor ParameterDistribution pardistr(name, distribution, 1); diff --git a/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp b/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp index 83ea71f1442..2a68eb0b224 100644 --- a/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp +++ b/Tests/UnitTests/Core/Parameters/ParameterPoolTest.cpp @@ -1,5 +1,4 @@ #include "Param/Base/ParameterPool.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/RealParameter.h" #include "Tests/GTestWrapper/google_test.h" @@ -22,7 +21,7 @@ TEST_F(ParameterPoolTest, addParameter) { EXPECT_EQ(pool.size(), 2u); // attempt to add same parameter twice - EXPECT_THROW(pool.addParameter(rp1), Exceptions::RuntimeErrorException); + EXPECT_THROW(pool.addParameter(rp1), std::runtime_error); // getting parameters EXPECT_EQ(pool.parameter("rp1"), rp1); @@ -58,7 +57,7 @@ TEST_F(ParameterPoolTest, matchedParameters) { // unique match EXPECT_EQ(rp2, pool.getUniqueMatch("*xxx*")); - EXPECT_THROW(pool.getUniqueMatch("*par*"), Exceptions::RuntimeErrorException); + EXPECT_THROW(pool.getUniqueMatch("*par*"), std::runtime_error); } TEST_F(ParameterPoolTest, setValue) { @@ -72,20 +71,18 @@ TEST_F(ParameterPoolTest, setValue) { // set single parameter value pool.setParameterValue("par1", 10.0); EXPECT_EQ(par1, 10.0); - EXPECT_THROW(pool.setParameterValue("non-existing", 10.0), Exceptions::RuntimeErrorException); + EXPECT_THROW(pool.setParameterValue("non-existing", 10.0), std::runtime_error); // set matched parameter values EXPECT_EQ(pool.setMatchedParametersValue("*par*", 99.0), 2); EXPECT_EQ(par1, 99.0); EXPECT_EQ(par3, 99.0); - EXPECT_THROW(pool.setMatchedParametersValue("*non-existing*", 10.0), - Exceptions::RuntimeErrorException); + EXPECT_THROW(pool.setMatchedParametersValue("*non-existing*", 10.0), std::runtime_error); // set unique match value pool.setUniqueMatchValue("*xxx*", 88.0); EXPECT_EQ(par2, 88.0); - EXPECT_THROW(pool.setUniqueMatchValue("*non-existing*", 10.0), - Exceptions::RuntimeErrorException); + EXPECT_THROW(pool.setUniqueMatchValue("*non-existing*", 10.0), std::runtime_error); } TEST_F(ParameterPoolTest, clone) { diff --git a/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp index 5e58f3e344a..40b34823cbc 100644 --- a/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp +++ b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp @@ -1,5 +1,4 @@ #include "Sample/Fresnel/FormFactorCoherentSum.h" -#include "Base/Types/Exceptions.h" #include "Sample/FFCompute/ComputeBA.h" #include "Sample/HardParticle/FormFactorDot.h" #include "Tests/GTestWrapper/google_test.h" @@ -16,6 +15,6 @@ TEST_F(FormFactorCoherentSumTest, RelAbundance) { EXPECT_EQ(0.0, ffw.radialExtension()); ffw.scaleRelativeAbundance(2.0); EXPECT_NEAR(0.5, ffw.relativeAbundance(), epsilon); - EXPECT_THROW(ffw.scaleRelativeAbundance(0.0), Exceptions::LogicErrorException); + EXPECT_THROW(ffw.scaleRelativeAbundance(0.0), std::runtime_error); EXPECT_EQ(0.0, ffw.radialExtension()); } diff --git a/Tests/UnitTests/Core/Sample/INodeTest.cpp b/Tests/UnitTests/Core/Sample/INodeTest.cpp index eb2a96c070e..c7982dde963 100644 --- a/Tests/UnitTests/Core/Sample/INodeTest.cpp +++ b/Tests/UnitTests/Core/Sample/INodeTest.cpp @@ -1,5 +1,4 @@ #include "Param/Node/INode.h" -#include "Base/Types/Exceptions.h" #include "Param/Base/ParameterPool.h" #include "Param/Base/RealParameter.h" #include "Param/Node/NodeUtils.h" @@ -122,7 +121,7 @@ TEST_F(INodeTest, nodePath) { EXPECT_EQ(NodeUtils::nodePath(*grandchild, child0), "/grandchild"); // Check if exception is thrown when grandchild doesn't belong to child's branch - EXPECT_THROW(NodeUtils::nodePath(*grandchild, child1), Exceptions::RuntimeErrorException); + EXPECT_THROW(NodeUtils::nodePath(*grandchild, child1), std::runtime_error); } //! Checking parameter tree for INode structure. diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i index d8f8115e0fb..d8530859416 100644 --- a/auto/Wrap/doxygenDevice.i +++ b/auto/Wrap/doxygenDevice.i @@ -1560,7 +1560,9 @@ init detector with beam settings // File: classIntensityDataIOFactory.xml %feature("docstring") IntensityDataIOFactory " -Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth \"*.gz\" or \"*.bz2\" the file will be zipped on the fly using appropriate algorithm. Usage: +Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth \"*.gz\" or \"*.bz2\" the file will be zipped on the fly using appropriate algorithm. + +Usage: C++ includes: IntensityDataIOFactory.h "; @@ -2353,7 +2355,7 @@ Sets concrete writing strategy. // File: classPolygon.xml %feature("docstring") Polygon " -A polygon in 2D space.Polygon defined by two arrays with x and y coordinates of points. Sizes of arrays should coincide. If polygon is unclosed (the last point doesn't repeat the first one), it will be closed automatically. +A polygon in 2D space. Polygon defined by two arrays with x and y coordinates of points. Sizes of arrays should coincide. If polygon is unclosed (the last point doesn't repeat the first one), it will be closed automatically. C++ includes: Polygon.h "; @@ -3159,22 +3161,22 @@ Returns true if area defined by two bins is inside or on border of polygon (more // File: classConvolve_1_1Workspace.xml -// File: namespace_0D113.xml +// File: namespace_0d112.xml -// File: namespace_0D33.xml +// File: namespace_0d33.xml -// File: namespace_0D56.xml +// File: namespace_0d56.xml -// File: namespace_0D58.xml +// File: namespace_0d58.xml -// File: namespace_0D62.xml +// File: namespace_0d62.xml -// File: namespace_0D68.xml +// File: namespace_0d68.xml // File: namespaceArrayUtils.xml @@ -3377,26 +3379,18 @@ for importing 2D array of doubles from python into OutputData // File: namespacepyfmt2.xml %feature("docstring") pyfmt2::representShape2D "std::string pyfmt2::representShape2D(const std::string &indent, const IShape2D *ishape, bool mask_value, std::function< std::string(double)> printValueFunc) - -Returns fixed Python code snippet that defines the function \"runSimulation\". "; %feature("docstring") pyfmt2::valueTimesUnit "std::string pyfmt2::valueTimesUnit(const RealParameter *par) - -Returns parameter value, followed by its unit multiplicator (like \"* nm\"). "; %feature("docstring") pyfmt2::argumentList "std::string pyfmt2::argumentList(const IParameterized *ip) - -Returns comma-separated list of parameter values, including unit multiplicator (like \"* nm\"). "; -%feature("docstring") pyfmt2::printDistribution "std::string pyfmt2::printDistribution(const IDistribution1D &par_distr, const std::string &units) - -Prints distribution with constructor parameters in given units. ba.DistributionGaussian(2.0*deg, 0.02*deg) +%feature("docstring") pyfmt2::printDistribution "std::string pyfmt2::printDistribution(const IDistribution1D &par_distr, const std::string &units=\"\") "; -%feature("docstring") pyfmt2::printParameterDistribution "std::string pyfmt2::printParameterDistribution(const ParameterDistribution &par_distr, const std::string &distVarName, const std::string &units) +%feature("docstring") pyfmt2::printParameterDistribution "std::string pyfmt2::printParameterDistribution(const ParameterDistribution &par_distr, const std::string &distVarName, const std::string &units=\"\") "; @@ -3663,9 +3657,6 @@ make Swappable // File: PyArrayImportUtils_8h.xml -// File: PyFmt2_8cpp.xml - - // File: PyFmt2_8h.xml diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py index 1ca03058809..0af965feaa2 100644 --- a/auto/Wrap/libBornAgainDevice.py +++ b/auto/Wrap/libBornAgainDevice.py @@ -3398,7 +3398,7 @@ class Polygon(IShape2D): r""" - A polygon in 2D space.Polygon defined by two arrays with x and y coordinates of points. Sizes of arrays should coincide. If polygon is unclosed (the last point doesn't repeat the first one), it will be closed automatically. + A polygon in 2D space. Polygon defined by two arrays with x and y coordinates of points. Sizes of arrays should coincide. If polygon is unclosed (the last point doesn't repeat the first one), it will be closed automatically. C++ includes: Polygon.h @@ -5949,7 +5949,9 @@ class IntensityDataIOFactory(object): r""" - Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth "*.gz" or "*.bz2" the file will be zipped on the fly using appropriate algorithm. Usage: + Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth "*.gz" or "*.bz2" the file will be zipped on the fly using appropriate algorithm. + + Usage: C++ includes: IntensityDataIOFactory.h @@ -5993,7 +5995,9 @@ class IntensityDataIOFactory(object): __init__(IntensityDataIOFactory self) -> IntensityDataIOFactory - Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth "*.gz" or "*.bz2" the file will be zipped on the fly using appropriate algorithm. Usage: + Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth "*.gz" or "*.bz2" the file will be zipped on the fly using appropriate algorithm. + + Usage: C++ includes: IntensityDataIOFactory.h diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp index 409a15b1937..f46ca1ba0d5 100644 --- a/auto/Wrap/libBornAgainDevice_wrap.cpp +++ b/auto/Wrap/libBornAgainDevice_wrap.cpp @@ -48651,7 +48651,9 @@ static PyMethodDef SwigMethods[] = { "new_IntensityDataIOFactory() -> IntensityDataIOFactory\n" "\n" "\n" - "Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth \"*.gz\" or \"*.bz2\" the file will be zipped on the fly using appropriate algorithm. Usage:\n" + "Provides users with possibility to read and write IntensityData from/to files in different format. Type of the file will be deduced from file name. *.txt - ASCII file with 2D array [nrow][ncol], layout as in numpy. *.int - BornAgain internal ASCII format. *.tif - 32-bits tiff file. If file name ends woth \"*.gz\" or \"*.bz2\" the file will be zipped on the fly using appropriate algorithm.\n" + "\n" + "Usage:\n" "\n" "C++ includes: IntensityDataIOFactory.h\n" "\n" -- GitLab