smart_house_lib/
errors.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum GetDataError {
5    #[error("Not found data")]
6    NotFound,
7}
8pub type GetDataResult<T> = Result<T, GetDataError>;
9
10#[derive(Debug, Error)]
11pub enum AddDataError {
12    #[error("Unique constraint error")]
13    UniqueConstraint,
14}
15pub type AddDataResult<T> = Result<T, AddDataError>;
16
17#[derive(Debug, Error)]
18pub enum RemoveDataError {
19    #[error("Not found element")]
20    NotFound,
21}
22pub type RemoveDataResult<T> = Result<T, RemoveDataError>;
23
24// #[derive(Debug, Error)]
25// pub enum DeviceError {
26//     #[error("Resource busy at the moment")]
27//     ThermometerError(#[from] ThermometerError)
28// }
29
30#[derive(Debug, Error)]
31pub enum ThermometerError {
32    #[error("Resource busy at the moment: ip `{0}`")]
33    Busy(String),
34    #[error("Receiving finish with error")]
35    ReceiveError(#[from] udp_wrapper::error::ReceiveError),
36    #[error("Thermometer binding with error")]
37    BindError(#[from] udp_wrapper::error::BindError),
38    #[error("Parsing temperature to float finish with error: `{0}`")]
39    ParseFloatError(String),
40}
41
42#[derive(Debug, Error)]
43pub enum RosetteError {
44    #[error("Resource busy at the moment")]
45    ServerNotFound(#[from] tcp_wrapper::error::ConnectError),
46    #[error("Getting data for rosette finish with error")]
47    GetDataError(#[from] tcp_wrapper::error::RequestError),
48    #[error("Parsing power to int finish with error `{0}`")]
49    ParsePowerError(String),
50}