1use thiserror::Error;
7
8#[derive(Debug, Error)]
10pub enum Error {
11 #[error("HTTP request failed: {0}")]
12 HttpError(String),
13
14 #[error("HTTP status error: {0}")]
15 HttpStatusError(u16),
16
17 #[error("Serialization error: {0}")]
18 SerializationError(String),
19
20 #[error("API error: {message}")]
21 ApiError { message: String },
22
23 #[error("Connection error: {0}")]
24 ConnectionError(String),
25
26 #[error("Invalid URL: {0}")]
27 InvalidUrlError(#[from] url::ParseError),
28
29 #[error("Request timeout after {0} seconds")]
30 TimeoutError(u64),
31
32 #[error("Maximum retry attempts ({0}) exceeded")]
33 MaxRetriesExceededError(u32),
34
35 #[error("Stream error: {0}")]
37 StreamError(String),
38}
39
40impl From<reqwest::Error> for Error {
41 fn from(err: reqwest::Error) -> Self {
42 Error::HttpError(err.to_string())
43 }
44}
45
46impl From<serde_json::Error> for Error {
47 fn from(err: serde_json::Error) -> Self {
48 Error::SerializationError(err.to_string())
49 }
50}
51
52pub type Result<T> = std::result::Result<T, Error>;