Skip to content

Commit 1b67b11

Browse files
committed
use shared_ptr and make dtors override = default
1 parent 546d782 commit 1b67b11

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/viam/sdk/common/exception.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Exception::Exception(ErrorCondition condition, const std::string& what)
1010

1111
Exception::Exception(const std::string& what) : Exception(ErrorCondition::k_general, what) {};
1212

13-
Exception::~Exception() = default;
14-
1513
const std::error_condition& Exception::condition() const noexcept {
1614
return condition_;
1715
};
@@ -49,9 +47,7 @@ std::error_condition make_error_condition(ErrorCondition e) {
4947

5048
GRPCException::GRPCException(const grpc::Status* status)
5149
: Exception(ErrorCondition::k_grpc, status->error_message()),
52-
status_(std::make_unique<grpc::Status>(*status)) {}
53-
54-
GRPCException::~GRPCException() = default;
50+
status_(std::make_shared<grpc::Status>(*status)) {}
5551

5652
const grpc::Status* GRPCException::status() const noexcept {
5753
return status_.get();

src/viam/sdk/common/exception.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class Exception : public std::runtime_error {
4242
public:
4343
explicit Exception(ErrorCondition condition, const std::string& what);
4444
explicit Exception(const std::string& what);
45-
virtual ~Exception();
45+
46+
~Exception() override = default;
4647

4748
const std::error_condition& condition() const noexcept;
4849

@@ -56,12 +57,12 @@ class Exception : public std::runtime_error {
5657
class GRPCException : public Exception {
5758
public:
5859
explicit GRPCException(const grpc::Status* status);
59-
~GRPCException();
60+
~GRPCException() override = default;
6061

6162
const grpc::Status* status() const noexcept;
6263

6364
private:
64-
std::unique_ptr<grpc::Status> status_;
65+
std::shared_ptr<grpc::Status> status_;
6566
};
6667

6768
} // namespace sdk

0 commit comments

Comments
 (0)