1use crate::ParseError;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum Error {
6 #[error("serialport error: {0}")]
7 SerialPort(#[from] serialport::Error),
8 #[error("utf8 error: {0}")]
9 Utf8(#[from] std::str::Utf8Error),
10 #[error("io error: {0}")]
11 Io(#[from] std::io::Error),
12 #[error("unexpected at response: {0}")]
13 UnexpectedResponse(String),
14 #[error("partial response after timeout: \"{0}\"")]
15 PartialResponse(String),
16 #[error("enabled to find port with pid = {vid} abd vid = {pid}")]
17 PortNotFound { vid: u16, pid: u16 },
18 #[error("parse error: {0}")]
19 Parse(#[from] ParseError),
20 #[error("wrote incorrect amount of bytes: {0} instead of {1}")]
21 IncorrectWrite(usize, usize),
22 #[error("ack was not received")]
23 Nack,
24 #[error("failed to parse rssi/snr from: {0}")]
25 FailedToParseRssiSnr(String),
26 #[error("failed to parse rssi from: {0}")]
27 FailedToParseRssiInt(std::num::ParseIntError),
28 #[error("failed to parse snr from: {0}")]
29 FailedToParseSnrF32(std::num::ParseFloatError),
30 #[error("invalid datarate string: {0}")]
31 InvalidDatarateStr(String),
32 #[error("modem is busy")]
33 Busy,
34}