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 {
20 status: u16,
21 message: String,
22 },
23
24 #[error("Invalid input: {0}")]
26 ValidationError(String),
27}
28
29impl From<serde_json::Error> for ApiError {
31 fn from(err: serde_json::Error) -> Self {
32 ApiError::DeserializationError(err.to_string())
33 }
34}