1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Error, Debug)]
6pub enum Error {
7 #[error("HTTP request failed: {0}")]
9 Request(#[from] reqwest::Error),
10
11 #[error("API error (code {code}): {message}")]
13 Api { code: i32, message: String },
14
15 #[error("invalid API key: the Govee API rejected the Govee-API-Key header")]
17 InvalidApiKey,
18
19 #[error("rate limited by the Govee API{}", match .retry_after_secs {
21 Some(secs) => format!(" (retry after {secs}s)"),
22 None => String::new(),
23 })]
24 RateLimited { retry_after_secs: Option<u64> },
25
26 #[error("Govee API server error (HTTP {status})")]
28 Server { status: u16 },
29
30 #[error("Failed to parse JSON response: {0}")]
31 Json(#[from] serde_json::Error),
32
33 #[error("Invalid response format: {0}")]
34 InvalidResponse(String),
35
36 #[error("Device not found: {0}")]
37 DeviceNotFound(String),
38}