1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::io::Error as IoError;

#[derive(thiserror::Error, Debug)]
pub enum SocketError {
    #[error("Socket io {msg}")]
    Io { source: IoError, msg: String },
    #[error("Socket closed")]
    SocketClosed,
    #[error("Socket is stale")]
    SocketStale,
}

impl From<IoError> for SocketError {
    fn from(err: IoError) -> Self {
        let msg = err.to_string();
        SocketError::Io { source: err, msg }
    }
}