Tidied exceptions

This commit is contained in:
Nav
2024-11-23 21:09:33 +00:00
parent 9aef4be2f1
commit 282086eaa2
8 changed files with 40 additions and 16 deletions

View File

@@ -69,6 +69,7 @@
#include "Exceptions/DebugServerInterrupted.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Exceptions/FatalErrorException.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
namespace DebugServer::Gdb
@@ -288,6 +289,10 @@ namespace DebugServer::Gdb
// Server was interrupted by an event
Logger::debug("GDB RSP interrupted");
return;
} catch (const ::Exceptions::FatalErrorException& exception) {
this->endDebugSession();
throw exception;
}
}
@@ -547,6 +552,10 @@ namespace DebugServer::Gdb
Logger::debug("GDB RSP interrupted");
return;
} catch (const ::Exceptions::FatalErrorException& exception) {
this->endDebugSession();
throw exception;
} catch (const ::Exceptions::Exception& exception) {
Logger::error("Failed to handle target execution state changed event - " + exception.getMessage());
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "Exception.hpp"
namespace Exceptions
{
class FatalErrorException: public Exception
{
public:
explicit FatalErrorException(const std::string& message)
: Exception(message)
{}
};
}

View File

@@ -1,15 +1,15 @@
#pragma once
#include "Exception.hpp"
#include "FatalErrorException.hpp"
#include "src/Services/PathService.hpp"
namespace Exceptions
{
class InternalFatalErrorException: public Exception
class InternalFatalErrorException: public FatalErrorException
{
public:
explicit InternalFatalErrorException(const std::string& message)
: Exception(
: FatalErrorException(
"Internal fatal error - " + message + " - please report this via "
+ Services::PathService::homeDomainName() + "/report-issue"
)

View File

@@ -1,14 +1,14 @@
#pragma once
#include "Exception.hpp"
#include "FatalErrorException.hpp"
namespace Exceptions
{
class InvalidConfig: public Exception
class InvalidConfig: public FatalErrorException
{
public:
explicit InvalidConfig(const std::string& message)
: Exception(message)
: FatalErrorException(message)
{}
};
}

View File

@@ -1,14 +1,14 @@
#pragma once
#include "Exception.hpp"
#include "FatalErrorException.hpp"
namespace Exceptions
{
class TargetControllerStartupFailure: public Exception
class TargetControllerStartupFailure: public FatalErrorException
{
public:
explicit TargetControllerStartupFailure(const std::string& message)
: Exception(message)
: FatalErrorException(message)
{}
};
}

View File

@@ -1,14 +1,14 @@
#pragma once
#include "src/Exceptions/Exception.hpp"
#include "src/Exceptions/FatalErrorException.hpp"
namespace Exceptions
{
class DeviceFailure: public Exception
class DeviceFailure: public FatalErrorException
{
public:
explicit DeviceFailure(const std::string& message)
: Exception(message)
: FatalErrorException(message)
{}
};
}

View File

@@ -4,11 +4,11 @@
namespace Exceptions
{
class DeviceNotFound: public Exception
class DeviceNotFound: public FatalErrorException
{
public:
explicit DeviceNotFound(const std::string& message)
: Exception(message)
: FatalErrorException(message)
{}
};
}

View File

@@ -15,6 +15,7 @@
#include "src/Services/StringService.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/FatalErrorException.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
namespace TargetController
@@ -455,7 +456,7 @@ namespace TargetController
this->registerCommandResponse(commandId, commandHandlerIt->second(*(command.get())));
} catch (const DeviceFailure& exception) {
} catch (const FatalErrorException& exception) {
this->registerCommandResponse(
commandId,
std::make_unique<Responses::Error>(exception.getMessage())