pinecone_rs/
error.rs

1//! pinecone-wasm Errors
2
3use crate::rest::models::PineconeErrorResponse;
4use reqwest::{Method, Response, StatusCode};
5use std::result;
6use thiserror::Error as ThisError;
7
8/// result allias where the Err term is pine-client::Error
9pub type Result<T> = result::Result<T, Error>;
10
11/// A set of errors that can occur in the Pinecone Client.
12#[derive(Debug, ThisError)]
13#[non_exhaustive]
14pub enum Error {
15    /// An error for when an invalid argument is used / given.
16    #[error("Invalid Argument for {name} found {found} expected {expected}")]
17    ArgumentError {
18        /// Name of the argument.
19        name: String,
20        /// Found value or description of found value.
21        found: String,
22        /// Expected value or description of expected value.
23        expected: String,
24    },
25
26    /// This is the error used when request fails to make a request.
27    #[error("Reqwest Error")]
28    ReqwestError(reqwest::Error),
29
30    /// An error returned when reqwest fails to do an action while the overall request is.
31    /// successfull, it is used currently for when a request goes through but a json decode fails.
32    #[error("Reqwest Response error")]
33    ReqwestResponseError(StatusCode, reqwest::Error),
34
35    /// When pinecone sends their [`PineconeErrorResponse`] to the client.
36    #[error("Finetune Failed with Response with Status Code {0:?} {1:?} {2:?}")]
37    PineconeResponseError(StatusCode, Option<PineconeErrorResponse>, Option<String>),
38
39    /// This error is used when Pinecone fails to return a [`PineconeErrorResponse`]
40    #[error("This request has failed")]
41    PineconeError(Response),
42
43    /// An error that describes an incorrectly sized vector.
44    #[error("Vector of id {id} had dimension {found} expected dimension size of {expected}")]
45    VectorDimensionError {
46        /// The dimension found.
47        found: u32,
48        /// The expected dimension.
49        expected: u32,
50        /// The Vector id.
51        id: String,
52    },
53
54    /// An error used for when the url value within an IndexDescription can't be found.
55    #[error("URL is not available within [`pine_client::http::models::DescribeStatus`]")]
56    URLNotAvailable,
57
58    /// This is an internal error used for internal checks. This **should** never actually happen.
59    #[error("Unsupported method: {}", method.as_str())]
60    UnsupportedMethod {
61        /// The unsupported method
62        method: Method,
63    },
64}