From 6b7f0fd234ac36c6c983ab79dea3c38f8ffb02c9 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 10 Dec 2022 19:23:06 +0000 Subject: [PATCH] Tidying --- .../Exceptions/ClientCommunicationError.hpp | 12 ++++++------ .../Gdb/Exceptions/ClientDisconnected.hpp | 8 -------- .../Gdb/Exceptions/ClientNotSupported.hpp | 12 ++++++------ src/DebugServer/Gdb/GdbRspDebugServer.cpp | 2 +- src/Exceptions/Exception.hpp | 18 +++++++++--------- 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp b/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp index 3d7e9090..d03f12ae 100644 --- a/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp +++ b/src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp @@ -13,13 +13,13 @@ namespace Bloom::DebugServer::Gdb::Exceptions class ClientCommunicationError: public Bloom::Exceptions::Exception { public: - explicit ClientCommunicationError(const std::string& message): Bloom::Exceptions::Exception(message) { - this->message = message; - } + explicit ClientCommunicationError(const std::string& message) + : Bloom::Exceptions::Exception(message) + {} - explicit ClientCommunicationError(const char* message): Bloom::Exceptions::Exception(message) { - this->message = std::string(message); - } + explicit ClientCommunicationError(const char* message) + : Bloom::Exceptions::Exception(message) + {} explicit ClientCommunicationError() = default; }; diff --git a/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp b/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp index 33c991c7..5a557930 100644 --- a/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp +++ b/src/DebugServer/Gdb/Exceptions/ClientDisconnected.hpp @@ -14,14 +14,6 @@ namespace Bloom::DebugServer::Gdb::Exceptions class ClientDisconnected: public Bloom::Exceptions::Exception { public: - explicit ClientDisconnected(const std::string& message): Bloom::Exceptions::Exception(message) { - this->message = message; - } - - explicit ClientDisconnected(const char* message): Bloom::Exceptions::Exception(message) { - this->message = std::string(message); - } - explicit ClientDisconnected() = default; }; } diff --git a/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp b/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp index 1ec88c81..df6deae6 100644 --- a/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp +++ b/src/DebugServer/Gdb/Exceptions/ClientNotSupported.hpp @@ -13,13 +13,13 @@ namespace Bloom::DebugServer::Gdb::Exceptions class ClientNotSupported: public Bloom::Exceptions::Exception { public: - explicit ClientNotSupported(const std::string& message): Bloom::Exceptions::Exception(message) { - this->message = message; - } + explicit ClientNotSupported(const std::string& message) + : Bloom::Exceptions::Exception(message) + {} - explicit ClientNotSupported(const char* message): Bloom::Exceptions::Exception(message) { - this->message = std::string(message); - } + explicit ClientNotSupported(const char* message) + : Bloom::Exceptions::Exception(message) + {} explicit ClientNotSupported() = default; }; diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.cpp b/src/DebugServer/Gdb/GdbRspDebugServer.cpp index 286ed981..3fc5d910 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.cpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.cpp @@ -179,7 +179,7 @@ namespace Bloom::DebugServer::Gdb this->targetControllerConsole.resetTarget(); } - auto commandPacket = this->waitForCommandPacket(); + const auto commandPacket = this->waitForCommandPacket(); if (commandPacket) { commandPacket->handle(this->activeDebugSession.value(), this->targetControllerConsole); diff --git a/src/Exceptions/Exception.hpp b/src/Exceptions/Exception.hpp index 943a7472..c6b3da5a 100644 --- a/src/Exceptions/Exception.hpp +++ b/src/Exceptions/Exception.hpp @@ -11,14 +11,6 @@ namespace Bloom::Exceptions : std::runtime_error("") {} - virtual ~Exception() = default; - - Exception(const Exception& other) noexcept = default; - Exception(Exception&& other) = default; - - Exception& operator = (const Exception& other) = default; - Exception& operator = (Exception&& other) = default; - explicit Exception(const std::string& message) : std::runtime_error(message.c_str()) , message(message) @@ -29,11 +21,19 @@ namespace Bloom::Exceptions , message(std::string(message)) {} + virtual ~Exception() = default; + + Exception(const Exception& other) noexcept = default; + Exception(Exception&& other) = default; + + Exception& operator = (const Exception& other) = default; + Exception& operator = (Exception&& other) = default; + const char* what() const noexcept override { return this->message.c_str(); } - std::string getMessage() const { + const std::string& getMessage() const { return this->message; }