Cppinecone
A C++ client for the Pinecone vector database
error.hpp
Go to the documentation of this file.
1 #pragma once
7 #include <cstdint>
8 #include <string>
9 #include <vector>
10 
11 #include <nlohmann/json.hpp>
12 
13 namespace pinecone::types
14 {
15 
19 struct error_detail {
20  NLOHMANN_DEFINE_TYPE_INTRUSIVE(error_detail, typeUrl, value)
21 
22  [[nodiscard]] auto type_url() const noexcept -> std::string const& { return typeUrl; }
23 
24  [[nodiscard]] auto detail_value() const noexcept -> std::string const& { return value; }
25 
26  private:
27  std::string typeUrl;
28  std::string value;
29 };
30 
41 struct api_error {
42  NLOHMANN_DEFINE_TYPE_INTRUSIVE(api_error, code, message, details)
43 
44  [[nodiscard]] auto error_code() const noexcept -> int32_t { return code; }
45 
46  [[nodiscard]] auto error_message() const noexcept -> std::string const& { return message; }
47 
48  [[nodiscard]] auto error_details() const noexcept -> std::vector<error_detail> const&
49  {
50  return details;
51  }
52 
53  private:
54  int32_t code;
55  std::string message;
57 };
58 } // namespace pinecone::types
An error response returned by the Pinecone API.
Definition: error.hpp:41
Pinecone API error details. Should only be accessed via api_error.
Definition: error.hpp:19