This simple patch adds support for storing the HTTP error description that Vector Store client receives from vector store. Until now it was just printed to the log but it was not returned. For this reason it was not forwarded to the drivers which forced users to access ScyllaDB server logs to understand what is wrong with Vector Store. This patch also updates formatter to print the message next to the error code. Fixes: VECTOR-189
59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
/*
|
|
* Copyright (C) 2025-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
#include <seastar/http/reply.hh>
|
|
#include <seastar/core/sstring.hh>
|
|
#include <fmt/format.h>
|
|
|
|
namespace vector_search {
|
|
|
|
/// The service is disabled.
|
|
struct disabled_error {};
|
|
|
|
/// The operation was aborted.
|
|
struct aborted_error {};
|
|
|
|
/// The vector-store addr is unavailable (not possible to get an addr from the dns service).
|
|
struct addr_unavailable_error {};
|
|
|
|
/// The vector-store service is unavailable.
|
|
struct service_unavailable_error {};
|
|
|
|
/// The error from the vector-store service.
|
|
struct service_error {
|
|
seastar::http::reply::status_type status; ///< The HTTP status code from the vector-store service.
|
|
seastar::sstring message; ///< The error message from the vector-store service.
|
|
};
|
|
|
|
/// An unsupported reply format from the vector-store service.
|
|
struct service_reply_format_error {};
|
|
|
|
struct error_visitor {
|
|
seastar::sstring operator()(service_error e) const {
|
|
return fmt::format("Vector Store error: HTTP status {}, message: {}", e.status, e.message);
|
|
}
|
|
seastar::sstring operator()(disabled_error) const {
|
|
return fmt::format("Vector Store is disabled");
|
|
}
|
|
seastar::sstring operator()(aborted_error) const {
|
|
return fmt::format("Vector Store request was aborted");
|
|
}
|
|
seastar::sstring operator()(addr_unavailable_error) const {
|
|
return fmt::format("Vector Store service address could not be fetched from DNS");
|
|
}
|
|
seastar::sstring operator()(service_unavailable_error) const {
|
|
return fmt::format("Vector Store service is unavailable");
|
|
}
|
|
seastar::sstring operator()(service_reply_format_error) const {
|
|
return fmt::format("Vector Store returned an invalid JSON");
|
|
}
|
|
};
|
|
|
|
} // namespace vector_search
|