1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum ApiError {
5 #[error("Failed to create HTTP client: {0}")]
7 ClientCreationError(String),
8
9 #[error("HTTP request failed: {0}")]
11 RequestError(#[from] reqwest::Error),
12
13 #[error("Failed to deserialize response: {0}")]
15 DeserializationError(String),
16
17 #[error("API error (status {status}): {message}")]
19 ApiError { status: u16, message: String },
20
21 #[error("Invalid input: {0}")]
23 ValidationError(String),
24}
25
26impl From<serde_json::Error> for ApiError {
28 fn from(err: serde_json::Error) -> Self {
29 ApiError::DeserializationError(err.to_string())
30 }
31}