openrgb/
error.rs

1use thiserror::Error;
2
3/// Errors returned by [OpenRGB client](crate::OpenRGB).
4#[derive(Error, Debug)]
5pub enum OpenRGBError {
6    /// Failed opening connection to OpenRGB server.
7    #[error("Failed opening connection to OpenRGB server at {addr:?}")]
8    ConnectionError {
9        /// OpenRGB server address.
10        addr: String,
11
12        /// Source error.
13        #[source]
14        source: std::io::Error,
15    },
16
17    /// Communication failure with OpenRGB server.
18    #[error("Failed exchanging data with OpenRGB server")]
19    CommunicationError {
20
21        /// Source error.
22        #[source]
23        #[from]
24        source: std::io::Error,
25    },
26
27    /// Invalid encountered while communicating with OpenRGB server.
28    #[error("Invalid data encountered while communicating with OpenRGB server: {0}")]
29    ProtocolError(String),
30
31    /// Server does not support operation.
32    #[error("{operation:?} is only supported since protocol version {min_protocol_version:?}, but version {current_protocol_version:?} is in use. Try upgrading the OpenRGB server.")]
33    UnsupportedOperation {
34
35        /// Operation name.
36        operation: String,
37
38        /// Protocol version in use by client.
39        current_protocol_version: u32,
40
41        /// Minimum required protocol version to use operation.
42        min_protocol_version: u32,
43    },
44}