ecc608_linux/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5    #[error("io error")]
6    IoError(#[from] std::io::Error),
7    #[error("timeout/retry error")]
8    Timeout,
9    #[error("ecc error {:?}", .0)]
10    Ecc(crate::command::EccError),
11    #[error("serial port error")]
12    SerialPort(#[from] serialport::Error),
13    #[error("invalid ecc address")]
14    InvalidAddress,
15}
16
17impl Error {
18    pub(crate) fn timeout() -> Self {
19        Self::Timeout
20    }
21
22    pub(crate) fn ecc(err: crate::command::EccError) -> Self {
23        Self::Ecc(err)
24    }
25
26    pub(crate) fn invalid_address() -> Self {
27        Self::InvalidAddress
28    }
29}