use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("HTTP request failed: {0}")]
Request(#[from] reqwest::Error),
#[error("Invalid URL: {0}")]
Url(#[from] url::ParseError),
#[error("API error ({status}): {message}")]
Api {
status: u16,
message: String,
},
#[error("Rate limit exceeded. Requests remaining: {requests_remaining:?}")]
RateLimited {
requests_remaining: Option<u32>,
},
#[error("Unauthorized: Invalid API key")]
Unauthorized,
#[error("Failed to deserialize response: {0}")]
Deserialization(#[from] serde_json::Error),
#[error("Missing required parameter: {0}")]
MissingParameter(&'static str),
#[error("Invalid parameter value for {parameter}: {message}")]
InvalidParameter {
parameter: &'static str,
message: String,
},
}
pub type Result<T> = std::result::Result<T, Error>;