Skip to main content

langchain_rust/embedding/
error.rs

1use async_openai::error::OpenAIError;
2#[cfg(feature = "mistralai")]
3use mistralai_client::v1::error::{ApiError, ClientError};
4#[cfg(feature = "ollama")]
5use ollama_rs::error::OllamaError;
6use reqwest::{Error as ReqwestError, StatusCode};
7use thiserror::Error;
8
9#[derive(Error, Debug)]
10#[non_exhaustive]
11pub enum EmbedderError {
12    #[error("Network request failed: {0}")]
13    RequestError(#[from] ReqwestError),
14
15    #[error("OpenAI error: {0}")]
16    OpenAIError(#[from] OpenAIError),
17
18    #[error("URL parsing error: {0}")]
19    UrlParseError(#[from] url::ParseError),
20
21    #[error("HTTP error: {status_code} {error_message}")]
22    HttpError {
23        status_code: StatusCode,
24        error_message: String,
25    },
26
27    #[error("FastEmbed error: {0}")]
28    FastEmbedError(String),
29
30    #[cfg(feature = "ollama")]
31    #[error("Ollama error: {0}")]
32    OllamaError(#[from] OllamaError),
33
34    #[cfg(feature = "mistralai")]
35    #[error("MistralAI Client error: {0}")]
36    MistralAIClientError(#[from] ClientError),
37
38    #[cfg(feature = "mistralai")]
39    #[error("MistralAI API error: {0}")]
40    MistralAIApiError(#[from] ApiError),
41
42    #[cfg(feature = "bedrock")]
43    #[error("Bedrock error: {0}")]
44    BedrockError(String),
45}