1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum OpenRouterError {
5 #[error("HTTP request failed: {0}")]
6 HttpError(#[from] reqwest::Error),
7
8 #[error("JSON serialization/deserialization failed: {0}")]
9 JsonError(#[from] serde_json::Error),
10
11 #[error("API error: {code} - {message}")]
12 ApiError { code: u16, message: String },
13
14 #[error("Authentication failed: {0}")]
15 AuthenticationError(String),
16
17 #[error("Rate limit exceeded")]
18 RateLimitError,
19
20 #[error("Invalid request: {0}")]
21 InvalidRequest(String),
22
23 #[error("Stream error: {0}")]
24 StreamError(String),
25
26 #[error("Configuration error: {0}")]
27 ConfigError(String),
28}
29
30pub type Result<T> = std::result::Result<T, OpenRouterError>;