unifi_rs/errors.rs
1use thiserror::Error;
2
3/// Enum representing various errors that can occur in the UniFi client library.
4#[derive(Debug, Error)]
5pub enum UnifiError {
6 /// Represents an HTTP error, wrapping the underlying `reqwest::Error`.
7 #[error("HTTP error: {0}")]
8 Http(#[from] reqwest::Error),
9
10 /// Represents an API error, containing the status code and error message.
11 #[error("API error: {status_code} - {message}")]
12 Api {
13 /// The HTTP status code returned by the API.
14 status_code: u16,
15 /// The error message returned by the API.
16 message: String,
17 },
18
19 /// Represents an error when parsing a URL, wrapping the underlying `url::ParseError`.
20 #[error("Invalid URL: {0}")]
21 Url(#[from] url::ParseError),
22
23 /// Represents a configuration error, containing a descriptive error message.
24 #[error("Configuration error: {0}")]
25 Config(String),
26}