mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
fix: Fix exception info is missing (#33393)
Replace based std::exception to prevent "object slicing" issue: https://github.com/milvus-io/milvus/issues/33392 Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
parent
af71116499
commit
5cf4161394
@ -14,6 +14,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include "Exception.h"
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -55,7 +56,7 @@ class Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
close(std::optional<std::exception> ex = std::nullopt) {
|
close(std::optional<MilvusException> ex = std::nullopt) {
|
||||||
if (ex.has_value()) {
|
if (ex.has_value()) {
|
||||||
ex_ = std::move(ex);
|
ex_ = std::move(ex);
|
||||||
}
|
}
|
||||||
@ -64,6 +65,6 @@ class Channel {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
oneapi::tbb::concurrent_bounded_queue<std::optional<T>> inner_{};
|
oneapi::tbb::concurrent_bounded_queue<std::optional<T>> inner_{};
|
||||||
std::optional<std::exception> ex_{};
|
std::optional<MilvusException> ex_{};
|
||||||
};
|
};
|
||||||
} // namespace milvus
|
} // namespace milvus
|
||||||
|
|||||||
@ -20,6 +20,22 @@
|
|||||||
|
|
||||||
namespace milvus {
|
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 {
|
class NotImplementedException : public std::exception {
|
||||||
public:
|
public:
|
||||||
explicit NotImplementedException(const std::string& msg)
|
explicit NotImplementedException(const std::string& msg)
|
||||||
|
|||||||
@ -820,7 +820,7 @@ LoadFieldDatasFromRemote(const std::vector<std::string>& remote_files,
|
|||||||
channel->close();
|
channel->close();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
LOG_INFO("failed to load data from remote: {}", e.what());
|
LOG_INFO("failed to load data from remote: {}", e.what());
|
||||||
channel->close(std::move(e));
|
channel->close(MilvusException(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user