1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5 #[error("HTTP request failed: {0}")]
6 Http(#[from] reqwest::Error),
7
8 #[error("API error {status}: {message}")]
9 Api { status: u16, message: String },
10
11 #[error("Authentication error: {0}")]
12 Auth(String),
13
14 #[error("JSON error: {0}")]
15 Json(#[from] serde_json::Error),
16
17 #[error("URL parse error: {0}")]
18 Url(#[from] url::ParseError),
19
20 #[error("Missing required field: {0}")]
21 MissingField(String),
22
23 #[error("Rate limited (HTTP 429): retry after {retry_after:?}s, circuit breaker open: {circuit_breaker}")]
24 RateLimited {
25 retry_after: Option<u64>,
26 circuit_breaker: bool,
27 },
28
29 #[error("Internal error: {0}")]
30 Internal(String),
31}
32
33pub type Result<T> = std::result::Result<T, Error>;