From 1b67b11a46b93e5740ab11c0d5178f8abfc999cf Mon Sep 17 00:00:00 2001 From: Lia Stratopoulos <167905060+lia-viam@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:47:35 -0500 Subject: [PATCH] use shared_ptr and make dtors override = default --- src/viam/sdk/common/exception.cpp | 6 +----- src/viam/sdk/common/exception.hpp | 7 ++++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/viam/sdk/common/exception.cpp b/src/viam/sdk/common/exception.cpp index 3a76efde4..eaf288041 100644 --- a/src/viam/sdk/common/exception.cpp +++ b/src/viam/sdk/common/exception.cpp @@ -10,8 +10,6 @@ Exception::Exception(ErrorCondition condition, const std::string& what) Exception::Exception(const std::string& what) : Exception(ErrorCondition::k_general, what) {}; -Exception::~Exception() = default; - const std::error_condition& Exception::condition() const noexcept { return condition_; }; @@ -49,9 +47,7 @@ std::error_condition make_error_condition(ErrorCondition e) { GRPCException::GRPCException(const grpc::Status* status) : Exception(ErrorCondition::k_grpc, status->error_message()), - status_(std::make_unique(*status)) {} - -GRPCException::~GRPCException() = default; + status_(std::make_shared(*status)) {} const grpc::Status* GRPCException::status() const noexcept { return status_.get(); diff --git a/src/viam/sdk/common/exception.hpp b/src/viam/sdk/common/exception.hpp index adfdc6ecd..c43c8fda7 100644 --- a/src/viam/sdk/common/exception.hpp +++ b/src/viam/sdk/common/exception.hpp @@ -42,7 +42,8 @@ class Exception : public std::runtime_error { public: explicit Exception(ErrorCondition condition, const std::string& what); explicit Exception(const std::string& what); - virtual ~Exception(); + + ~Exception() override = default; const std::error_condition& condition() const noexcept; @@ -56,12 +57,12 @@ class Exception : public std::runtime_error { class GRPCException : public Exception { public: explicit GRPCException(const grpc::Status* status); - ~GRPCException(); + ~GRPCException() override = default; const grpc::Status* status() const noexcept; private: - std::unique_ptr status_; + std::shared_ptr status_; }; } // namespace sdk