use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("HTTP request failed: {0}")]
Request(#[from] reqwest::Error),
#[error("API error (code {code}): {message}")]
Api { code: i32, message: String },
#[error("invalid API key: the Govee API rejected the Govee-API-Key header")]
InvalidApiKey,
#[error("rate limited by the Govee API{}", match .retry_after_secs {
Some(secs) => format!(" (retry after {secs}s)"),
None => String::new(),
})]
RateLimited { retry_after_secs: Option<u64> },
#[error("Govee API server error (HTTP {status})")]
Server { status: u16 },
#[error("Failed to parse JSON response: {0}")]
Json(#[from] serde_json::Error),
#[error("Invalid response format: {0}")]
InvalidResponse(String),
#[error("Device not found: {0}")]
DeviceNotFound(String),
}