Skip to main content

beeper_desktop_api/
error.rs

1//! Error types for Beeper API operations
2
3use thiserror::Error;
4
5/// Error type for Beeper API operations
6#[derive(Error, Debug)]
7pub enum BeeperError {
8    #[error("Beeper API is not reachable at {url}. Make sure Beeper Desktop is running and the API is enabled")]
9    ApiNotReachable { url: String },
10
11    #[error("Unauthorized - invalid or expired bearer token. Check your BEEPER_TOKEN variable")]
12    Unauthorized,
13
14    #[error("HTTP request failed: {0}")]
15    RequestError(#[from] reqwest::Error),
16
17    #[error("API error: {message} (code: {code})")]
18    ApiError { code: String, message: String },
19
20    #[error("Serialization error: {0}")]
21    SerializationError(#[from] serde_json::Error),
22
23    #[error("Missing required field: {0}")]
24    MissingField(String),
25
26    #[error("Invalid configuration: {0}")]
27    InvalidConfig(String),
28}
29
30/// Result type for Beeper API operations
31pub type Result<T> = std::result::Result<T, BeeperError>;