Refactored TDF parsing exceptions
This commit is contained in:
@@ -6,9 +6,10 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "MemorySegment.hpp"
|
#include "MemorySegment.hpp"
|
||||||
|
|
||||||
#include "src/Targets/TargetMemory.hpp"
|
#include "src/Targets/TargetMemory.hpp"
|
||||||
|
|
||||||
|
#include "Exceptions/InvalidTargetDescriptionDataException.hpp"
|
||||||
|
|
||||||
namespace Targets::TargetDescription
|
namespace Targets::TargetDescription
|
||||||
{
|
{
|
||||||
struct AddressSpace
|
struct AddressSpace
|
||||||
@@ -46,7 +47,7 @@ namespace Targets::TargetDescription
|
|||||||
const MemorySegment& getMemorySegment(std::string_view key) const {
|
const MemorySegment& getMemorySegment(std::string_view key) const {
|
||||||
const auto segment = this->tryGetMemorySegment(key);
|
const auto segment = this->tryGetMemorySegment(key);
|
||||||
if (!segment.has_value()) {
|
if (!segment.has_value()) {
|
||||||
throw Exceptions::Exception(
|
throw Exceptions::InvalidTargetDescriptionDataException(
|
||||||
"Failed to get memory segment \"" + std::string(key)
|
"Failed to get memory segment \"" + std::string(key)
|
||||||
+ "\" from address space in TDF - segment not found"
|
+ "\" from address space in TDF - segment not found"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,20 +1,14 @@
|
|||||||
#pragma once
|
#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:
|
public:
|
||||||
explicit TargetDescriptionParsingFailureException(const std::string& message)
|
explicit TargetDescriptionParsingFailureException(const std::string& message)
|
||||||
: Exception(message) {
|
: ::Exceptions::InternalFatalErrorException("Failed to parse target description file - " + 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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "MemorySegmentSection.hpp"
|
#include "MemorySegmentSection.hpp"
|
||||||
|
|
||||||
#include "src/Services/StringService.hpp"
|
#include "src/Services/StringService.hpp"
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "Exceptions/InvalidTargetDescriptionDataException.hpp"
|
||||||
|
|
||||||
namespace Targets::TargetDescription
|
namespace Targets::TargetDescription
|
||||||
{
|
{
|
||||||
@@ -72,7 +72,7 @@ namespace Targets::TargetDescription
|
|||||||
) const {
|
) const {
|
||||||
const auto propertyGroup = this->tryGetSection(keyStr);
|
const auto propertyGroup = this->tryGetSection(keyStr);
|
||||||
if (!propertyGroup.has_value()) {
|
if (!propertyGroup.has_value()) {
|
||||||
throw Exceptions::Exception(
|
throw Exceptions::InvalidTargetDescriptionDataException(
|
||||||
"Failed to get memory segment section \"" + std::string(keyStr)
|
"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"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
#include "src/Services/StringService.hpp"
|
#include "src/Services/StringService.hpp"
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "Exceptions/InvalidTargetDescriptionDataException.hpp"
|
||||||
|
|
||||||
namespace Targets::TargetDescription
|
namespace Targets::TargetDescription
|
||||||
{
|
{
|
||||||
@@ -67,7 +67,7 @@ namespace Targets::TargetDescription
|
|||||||
) const {
|
) const {
|
||||||
const auto propertyGroup = this->tryGetSubSection(keyStr);
|
const auto propertyGroup = this->tryGetSubSection(keyStr);
|
||||||
if (!propertyGroup.has_value()) {
|
if (!propertyGroup.has_value()) {
|
||||||
throw Exceptions::Exception(
|
throw Exceptions::InvalidTargetDescriptionDataException(
|
||||||
"Failed to get memory segment sub-section \"" + std::string(keyStr)
|
"Failed to get memory segment sub-section \"" + std::string(keyStr)
|
||||||
+ "\" from memory segment in TDF - sub-section not found"
|
+ "\" from memory segment in TDF - sub-section not found"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "src/Services/StringService.hpp"
|
#include "src/Services/StringService.hpp"
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "Exceptions/InvalidTargetDescriptionDataException.hpp"
|
||||||
|
|
||||||
namespace Targets::TargetDescription
|
namespace Targets::TargetDescription
|
||||||
{
|
{
|
||||||
@@ -68,7 +68,7 @@ namespace Targets::TargetDescription
|
|||||||
std::optional<std::reference_wrapper<const PropertyGroup>> getSubgroup(std::string_view keyStr) const {
|
std::optional<std::reference_wrapper<const PropertyGroup>> getSubgroup(std::string_view keyStr) const {
|
||||||
const auto propertyGroup = this->tryGetSubgroup(keyStr);
|
const auto propertyGroup = this->tryGetSubgroup(keyStr);
|
||||||
if (!propertyGroup.has_value()) {
|
if (!propertyGroup.has_value()) {
|
||||||
throw Exceptions::Exception(
|
throw Exceptions::InvalidTargetDescriptionDataException(
|
||||||
"Failed to get subgroup \"" + std::string(keyStr)
|
"Failed to get subgroup \"" + std::string(keyStr)
|
||||||
+ "\" from property group in TDF - subgroup not found"
|
+ "\" from property group in TDF - subgroup not found"
|
||||||
);
|
);
|
||||||
@@ -90,7 +90,7 @@ namespace Targets::TargetDescription
|
|||||||
const Property& getProperty(std::string_view key) const {
|
const Property& getProperty(std::string_view key) const {
|
||||||
const auto property = this->tryGetProperty(key);
|
const auto property = this->tryGetProperty(key);
|
||||||
if (!property.has_value()) {
|
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"
|
"Failed to get property \"" + std::string(key) + "\" from property group in TDF - property not found"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
namespace Targets::TargetDescription
|
namespace Targets::TargetDescription
|
||||||
{
|
{
|
||||||
using namespace Exceptions;
|
using namespace Exceptions;
|
||||||
|
using namespace ::Exceptions;
|
||||||
|
|
||||||
using Services::StringService;
|
using Services::StringService;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user