diff --git a/src/Targets/TargetDescription/AddressSpace.hpp b/src/Targets/TargetDescription/AddressSpace.hpp index 70080824..511e7b49 100644 --- a/src/Targets/TargetDescription/AddressSpace.hpp +++ b/src/Targets/TargetDescription/AddressSpace.hpp @@ -6,9 +6,10 @@ #include #include "MemorySegment.hpp" - #include "src/Targets/TargetMemory.hpp" +#include "Exceptions/InvalidTargetDescriptionDataException.hpp" + namespace Targets::TargetDescription { struct AddressSpace @@ -46,7 +47,7 @@ namespace Targets::TargetDescription const MemorySegment& getMemorySegment(std::string_view key) const { const auto segment = this->tryGetMemorySegment(key); if (!segment.has_value()) { - throw Exceptions::Exception( + throw Exceptions::InvalidTargetDescriptionDataException( "Failed to get memory segment \"" + std::string(key) + "\" from address space in TDF - segment not found" ); diff --git a/src/Targets/TargetDescription/Exceptions/InvalidTargetDescriptionDataException.hpp b/src/Targets/TargetDescription/Exceptions/InvalidTargetDescriptionDataException.hpp new file mode 100644 index 00000000..2ed126c7 --- /dev/null +++ b/src/Targets/TargetDescription/Exceptions/InvalidTargetDescriptionDataException.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include "src/Exceptions/InternalFatalErrorException.hpp" + +namespace Targets::TargetDescription::Exceptions +{ + class InvalidTargetDescriptionDataException: public ::Exceptions::InternalFatalErrorException + { + public: + explicit InvalidTargetDescriptionDataException(const std::string& message) + : ::Exceptions::InternalFatalErrorException("Missing/invalid data in TDF - " + message) + {} + }; +} diff --git a/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp b/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp index 4f183a4f..45de2910 100644 --- a/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp +++ b/src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp @@ -1,20 +1,14 @@ #pragma once -#include "src/Exceptions/Exception.hpp" +#include "src/Exceptions/InternalFatalErrorException.hpp" -namespace Exceptions +namespace Targets::TargetDescription::Exceptions { - class TargetDescriptionParsingFailureException: public Exception + class TargetDescriptionParsingFailureException: public ::Exceptions::InternalFatalErrorException { public: explicit TargetDescriptionParsingFailureException(const std::string& message) - : Exception(message) { - this->message = "Failed to parse target description file - " + message; - } - - explicit TargetDescriptionParsingFailureException(const char* message) - : Exception(message) { - this->message = "Failed to parse target description file - " + std::string(message); - } + : ::Exceptions::InternalFatalErrorException("Failed to parse target description file - " + message) + {} }; } diff --git a/src/Targets/TargetDescription/MemorySegment.hpp b/src/Targets/TargetDescription/MemorySegment.hpp index d1b0803e..9a7fe838 100644 --- a/src/Targets/TargetDescription/MemorySegment.hpp +++ b/src/Targets/TargetDescription/MemorySegment.hpp @@ -6,7 +6,7 @@ #include "MemorySegmentSection.hpp" #include "src/Services/StringService.hpp" -#include "src/Exceptions/Exception.hpp" +#include "Exceptions/InvalidTargetDescriptionDataException.hpp" namespace Targets::TargetDescription { @@ -72,9 +72,9 @@ namespace Targets::TargetDescription ) const { const auto propertyGroup = this->tryGetSection(keyStr); if (!propertyGroup.has_value()) { - throw Exceptions::Exception( + throw Exceptions::InvalidTargetDescriptionDataException( "Failed to get memory segment section \"" + std::string(keyStr) - + "\" from memory segment in TDF - section not found" + + "\" from memory segment in TDF - section not found" ); } diff --git a/src/Targets/TargetDescription/MemorySegmentSection.hpp b/src/Targets/TargetDescription/MemorySegmentSection.hpp index 6b4d25a7..150f61f6 100644 --- a/src/Targets/TargetDescription/MemorySegmentSection.hpp +++ b/src/Targets/TargetDescription/MemorySegmentSection.hpp @@ -9,7 +9,7 @@ #include #include "src/Services/StringService.hpp" -#include "src/Exceptions/Exception.hpp" +#include "Exceptions/InvalidTargetDescriptionDataException.hpp" namespace Targets::TargetDescription { @@ -67,7 +67,7 @@ namespace Targets::TargetDescription ) const { const auto propertyGroup = this->tryGetSubSection(keyStr); if (!propertyGroup.has_value()) { - throw Exceptions::Exception( + throw Exceptions::InvalidTargetDescriptionDataException( "Failed to get memory segment sub-section \"" + std::string(keyStr) + "\" from memory segment in TDF - sub-section not found" ); diff --git a/src/Targets/TargetDescription/PropertyGroup.hpp b/src/Targets/TargetDescription/PropertyGroup.hpp index ec7b4213..6e826b1a 100644 --- a/src/Targets/TargetDescription/PropertyGroup.hpp +++ b/src/Targets/TargetDescription/PropertyGroup.hpp @@ -9,7 +9,7 @@ #include #include "src/Services/StringService.hpp" -#include "src/Exceptions/Exception.hpp" +#include "Exceptions/InvalidTargetDescriptionDataException.hpp" namespace Targets::TargetDescription { @@ -68,7 +68,7 @@ namespace Targets::TargetDescription std::optional> getSubgroup(std::string_view keyStr) const { const auto propertyGroup = this->tryGetSubgroup(keyStr); if (!propertyGroup.has_value()) { - throw Exceptions::Exception( + throw Exceptions::InvalidTargetDescriptionDataException( "Failed to get subgroup \"" + std::string(keyStr) + "\" from property group in TDF - subgroup not found" ); @@ -90,7 +90,7 @@ namespace Targets::TargetDescription const Property& getProperty(std::string_view key) const { const auto property = this->tryGetProperty(key); if (!property.has_value()) { - throw Exceptions::Exception( + throw Exceptions::InvalidTargetDescriptionDataException( "Failed to get property \"" + std::string(key) + "\" from property group in TDF - property not found" ); } diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/TargetDescription/TargetDescriptionFile.cpp index 2dc659dd..9329aa28 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.cpp @@ -16,6 +16,7 @@ namespace Targets::TargetDescription { using namespace Exceptions; + using namespace ::Exceptions; using Services::StringService;