diff --git a/internal/core/src/common/Channel.h b/internal/core/src/common/Channel.h index f042945432..1dead83247 100644 --- a/internal/core/src/common/Channel.h +++ b/internal/core/src/common/Channel.h @@ -14,6 +14,7 @@ #include #include #include +#include "Exception.h" namespace milvus { template @@ -55,7 +56,7 @@ class Channel { } void - close(std::optional ex = std::nullopt) { + close(std::optional ex = std::nullopt) { if (ex.has_value()) { ex_ = std::move(ex); } @@ -64,6 +65,6 @@ class Channel { private: oneapi::tbb::concurrent_bounded_queue> inner_{}; - std::optional ex_{}; + std::optional ex_{}; }; } // namespace milvus diff --git a/internal/core/src/common/Exception.h b/internal/core/src/common/Exception.h index 68941ba567..d4f3863b9d 100644 --- a/internal/core/src/common/Exception.h +++ b/internal/core/src/common/Exception.h @@ -20,6 +20,22 @@ namespace milvus { +class MilvusException : public std::exception { + public: + explicit MilvusException(const std::string& msg) + : std::exception(), exception_message_(msg) { + } + const char* + what() const noexcept { + return exception_message_.c_str(); + } + virtual ~MilvusException() { + } + + private: + std::string exception_message_; +}; + class NotImplementedException : public std::exception { public: explicit NotImplementedException(const std::string& msg) diff --git a/internal/core/src/segcore/Utils.cpp b/internal/core/src/segcore/Utils.cpp index cee4a04c92..6349ad847a 100644 --- a/internal/core/src/segcore/Utils.cpp +++ b/internal/core/src/segcore/Utils.cpp @@ -820,7 +820,7 @@ LoadFieldDatasFromRemote(const std::vector& remote_files, channel->close(); } catch (std::exception& e) { LOG_INFO("failed to load data from remote: {}", e.what()); - channel->close(std::move(e)); + channel->close(MilvusException(e.what())); } }