use thiserror::Error;
pub use typesense_codegen::apis::{Error as ApiError, ResponseContent};
#[derive(Debug, Error)]
pub enum Error<E>
where
E: std::fmt::Debug + 'static,
ApiError<E>: std::error::Error + 'static,
{
#[error("All configured Typesense nodes failed to respond. Last error: {source}")]
AllNodesFailed {
#[source]
source: ApiError<E>,
},
#[error("An API or network error occurred: {0}")]
Api(#[from] ApiError<E>),
#[error("Failed to deserialize the API response into the target struct: {0}")]
Deserialization(#[from] serde_json::Error),
}
#[derive(Debug, Error)]
pub enum MultiSearchParseError {
#[error("Search result index {0} is out of bounds.")]
IndexOutOfBounds(usize),
#[error("The search at index {index} failed with an API error: {message}")]
ApiError {
index: usize,
message: String,
},
#[error("Failed to deserialize a document at index {index}: {source}")]
Deserialization {
index: usize,
#[source]
source: serde_json::Error,
},
}