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
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
Parse(String),
ConnectionReset,
Incomplete
}
impl std::fmt::Display for Error {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
let content = match self {
Error::Io(inner_error) => format!("io error: {}", inner_error),
Error::Parse(detail) => format!("parse error: {}", detail),
Error::ConnectionReset => format!("connection reset by peer"),
Error::Incomplete => format!("incomplete frame message in ws connection"),
};
write!(formatter, "{}", content)
}
}
impl std::error::Error for Error {}