langchain_rust/language_models/
error.rs1use async_openai::error::OpenAIError;
2#[cfg(feature = "ollama")]
3use ollama_rs::error::OllamaError;
4use reqwest::Error as ReqwestError;
5use serde_json::Error as SerdeJsonError;
6use thiserror::Error;
7use tokio::time::error::Elapsed;
8
9#[cfg(feature = "bedrock")]
10use crate::llm::BedrockError;
11use crate::llm::{AnthropicError, DeepseekError, QwenError};
12
13#[derive(Error, Debug)]
14pub enum LLMError {
15 #[error("OpenAI error: {0}")]
16 OpenAIError(#[from] OpenAIError),
17
18 #[error("Anthropic error: {0}")]
19 AnthropicError(#[from] AnthropicError),
20
21 #[error("Qwen error: {0}")]
22 QwenError(#[from] QwenError),
23
24 #[error("Deepseek error: {0}")]
25 DeepseekError(#[from] DeepseekError),
26
27 #[cfg(feature = "ollama")]
28 #[error("Ollama error: {0}")]
29 OllamaError(#[from] OllamaError),
30
31 #[cfg(feature = "bedrock")]
32 #[error("Bedrock error: {0}")]
33 BedrockError(#[from] BedrockError),
34
35 #[error("Network request failed: {0}")]
36 RequestError(#[from] ReqwestError),
37
38 #[error("JSON serialization/deserialization error: {0}")]
39 SerdeError(#[from] SerdeJsonError),
40
41 #[error("IO error: {0}")]
42 IoError(#[from] std::io::Error),
43
44 #[error("Operation timed out")]
45 Timeout(#[from] Elapsed),
46
47 #[error("Invalid URL: {0}")]
48 InvalidUrl(String),
49
50 #[error("Content not found in response: Expected at {0}")]
51 ContentNotFound(String),
52
53 #[error("Parsing error: {0}")]
54 ParsingError(String),
55
56 #[error("Error: {0}")]
57 OtherError(String),
58}