steelseries_sonar/
error.rs

1//! Error types for the SteelSeries Sonar API.
2
3use thiserror::Error;
4
5/// Errors that can occur when using the SteelSeries Sonar API.
6#[derive(Error, Debug)]
7pub enum SonarError {
8    #[error("SteelSeries Engine 3 not installed or not in the default location!")]
9    EnginePathNotFound,
10
11    #[error("SteelSeries server not accessible! Status code: {0}")]
12    ServerNotAccessible(u16),
13
14    #[error("SteelSeries Sonar is not enabled!")]
15    SonarNotEnabled,
16
17    #[error("SteelSeries Sonar is not ready yet!")]
18    ServerNotReady,
19
20    #[error("SteelSeries Sonar is not running!")]
21    ServerNotRunning,
22
23    #[error("Web server address not found")]
24    WebServerAddressNotFound,
25
26    #[error("Channel '{0}' not found")]
27    ChannelNotFound(String),
28
29    #[error("Slider '{0}' not found")]
30    SliderNotFound(String),
31
32    #[error("Invalid volume '{0}'! Value must be between 0.0 and 1.0!")]
33    InvalidVolume(f64),
34
35    #[error("Invalid mix volume '{0}'! Value must be between -1.0 and 1.0!")]
36    InvalidMixVolume(f64),
37
38    #[error("HTTP request error: {0}")]
39    Http(#[from] reqwest::Error),
40
41    #[error("JSON serialization/deserialization error: {0}")]
42    Json(#[from] serde_json::Error),
43
44    #[error("IO error: {0}")]
45    Io(#[from] std::io::Error),
46}
47
48/// Result type for SteelSeries Sonar operations.
49pub type Result<T> = std::result::Result<T, SonarError>;