1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::fmt::Display;
use std::fmt;
use rumqttc::ConnectionError;
#[derive(Debug)]
pub enum AWSIoTError {
AWSConnectionError,
IoError,
}
impl Display for AWSIoTError {
fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result {
match self {
AWSIoTError::AWSConnectionError => write!(f, "Problem connecting to AWS"),
AWSIoTError::IoError => write!(f, "Problem reading file"),
}
}
}
impl From<std::io::Error> for AWSIoTError {
fn from(_err: std::io::Error) -> AWSIoTError {
AWSIoTError::IoError
}
}
impl From<ConnectionError> for AWSIoTError {
fn from(_err: ConnectionError) -> AWSIoTError {
AWSIoTError::AWSConnectionError
}
}