Tidied exceptions
This commit is contained in:
@@ -69,6 +69,7 @@
|
|||||||
#include "Exceptions/DebugServerInterrupted.hpp"
|
#include "Exceptions/DebugServerInterrupted.hpp"
|
||||||
|
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "src/Exceptions/Exception.hpp"
|
||||||
|
#include "src/Exceptions/FatalErrorException.hpp"
|
||||||
#include "src/Exceptions/InvalidConfig.hpp"
|
#include "src/Exceptions/InvalidConfig.hpp"
|
||||||
|
|
||||||
namespace DebugServer::Gdb
|
namespace DebugServer::Gdb
|
||||||
@@ -288,6 +289,10 @@ namespace DebugServer::Gdb
|
|||||||
// Server was interrupted by an event
|
// Server was interrupted by an event
|
||||||
Logger::debug("GDB RSP interrupted");
|
Logger::debug("GDB RSP interrupted");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
} catch (const ::Exceptions::FatalErrorException& exception) {
|
||||||
|
this->endDebugSession();
|
||||||
|
throw exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,6 +552,10 @@ namespace DebugServer::Gdb
|
|||||||
Logger::debug("GDB RSP interrupted");
|
Logger::debug("GDB RSP interrupted");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
} catch (const ::Exceptions::FatalErrorException& exception) {
|
||||||
|
this->endDebugSession();
|
||||||
|
throw exception;
|
||||||
|
|
||||||
} catch (const ::Exceptions::Exception& exception) {
|
} catch (const ::Exceptions::Exception& exception) {
|
||||||
Logger::error("Failed to handle target execution state changed event - " + exception.getMessage());
|
Logger::error("Failed to handle target execution state changed event - " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/Exceptions/FatalErrorException.hpp
Normal file
14
src/Exceptions/FatalErrorException.hpp
Normal 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)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Exception.hpp"
|
#include "FatalErrorException.hpp"
|
||||||
#include "src/Services/PathService.hpp"
|
#include "src/Services/PathService.hpp"
|
||||||
|
|
||||||
namespace Exceptions
|
namespace Exceptions
|
||||||
{
|
{
|
||||||
class InternalFatalErrorException: public Exception
|
class InternalFatalErrorException: public FatalErrorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit InternalFatalErrorException(const std::string& message)
|
explicit InternalFatalErrorException(const std::string& message)
|
||||||
: Exception(
|
: FatalErrorException(
|
||||||
"Internal fatal error - " + message + " - please report this via "
|
"Internal fatal error - " + message + " - please report this via "
|
||||||
+ Services::PathService::homeDomainName() + "/report-issue"
|
+ Services::PathService::homeDomainName() + "/report-issue"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Exception.hpp"
|
#include "FatalErrorException.hpp"
|
||||||
|
|
||||||
namespace Exceptions
|
namespace Exceptions
|
||||||
{
|
{
|
||||||
class InvalidConfig: public Exception
|
class InvalidConfig: public FatalErrorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit InvalidConfig(const std::string& message)
|
explicit InvalidConfig(const std::string& message)
|
||||||
: Exception(message)
|
: FatalErrorException(message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Exception.hpp"
|
#include "FatalErrorException.hpp"
|
||||||
|
|
||||||
namespace Exceptions
|
namespace Exceptions
|
||||||
{
|
{
|
||||||
class TargetControllerStartupFailure: public Exception
|
class TargetControllerStartupFailure: public FatalErrorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TargetControllerStartupFailure(const std::string& message)
|
explicit TargetControllerStartupFailure(const std::string& message)
|
||||||
: Exception(message)
|
: FatalErrorException(message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "src/Exceptions/FatalErrorException.hpp"
|
||||||
|
|
||||||
namespace Exceptions
|
namespace Exceptions
|
||||||
{
|
{
|
||||||
class DeviceFailure: public Exception
|
class DeviceFailure: public FatalErrorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DeviceFailure(const std::string& message)
|
explicit DeviceFailure(const std::string& message)
|
||||||
: Exception(message)
|
: FatalErrorException(message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
namespace Exceptions
|
namespace Exceptions
|
||||||
{
|
{
|
||||||
class DeviceNotFound: public Exception
|
class DeviceNotFound: public FatalErrorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DeviceNotFound(const std::string& message)
|
explicit DeviceNotFound(const std::string& message)
|
||||||
: Exception(message)
|
: FatalErrorException(message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "src/Services/StringService.hpp"
|
#include "src/Services/StringService.hpp"
|
||||||
#include "src/Logger/Logger.hpp"
|
#include "src/Logger/Logger.hpp"
|
||||||
|
|
||||||
|
#include "src/Exceptions/FatalErrorException.hpp"
|
||||||
#include "src/Exceptions/InvalidConfig.hpp"
|
#include "src/Exceptions/InvalidConfig.hpp"
|
||||||
|
|
||||||
namespace TargetController
|
namespace TargetController
|
||||||
@@ -78,7 +79,7 @@ namespace TargetController
|
|||||||
while (this->getThreadState() == ThreadState::READY) {
|
while (this->getThreadState() == ThreadState::READY) {
|
||||||
this->refreshExecutionState();
|
this->refreshExecutionState();
|
||||||
|
|
||||||
TargetControllerComponent::notifier.waitForNotification(std::chrono::milliseconds(60));
|
TargetControllerComponent::notifier.waitForNotification(std::chrono::milliseconds(60 ));
|
||||||
|
|
||||||
this->processQueuedCommands();
|
this->processQueuedCommands();
|
||||||
this->eventListener->dispatchCurrentEvents();
|
this->eventListener->dispatchCurrentEvents();
|
||||||
@@ -455,7 +456,7 @@ namespace TargetController
|
|||||||
|
|
||||||
this->registerCommandResponse(commandId, commandHandlerIt->second(*(command.get())));
|
this->registerCommandResponse(commandId, commandHandlerIt->second(*(command.get())));
|
||||||
|
|
||||||
} catch (const DeviceFailure& exception) {
|
} catch (const FatalErrorException& exception) {
|
||||||
this->registerCommandResponse(
|
this->registerCommandResponse(
|
||||||
commandId,
|
commandId,
|
||||||
std::make_unique<Responses::Error>(exception.getMessage())
|
std::make_unique<Responses::Error>(exception.getMessage())
|
||||||
|
|||||||
Reference in New Issue
Block a user