openlegends_client/connection/
error.rs

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
use std::fmt::{Display, Formatter, Result};

#[derive(Debug)]
pub enum Error {
    TcpStream(std::io::Error),
    TlsConnector(native_tls::Error),
    TlsConnection(native_tls::HandshakeError<std::net::TcpStream>),
    Utf8(std::str::Utf8Error),
}

impl Display for Error {
    fn fmt(&self, f: &mut Formatter) -> Result {
        match self {
            Self::TcpStream(e) => {
                write!(f, "TCP error: `{e}`")
            }
            Self::TlsConnector(e) => {
                write!(f, "TLS error: `{e}`")
            }
            Self::TlsConnection(e) => {
                write!(f, "Connection error: `{e}`")
            }
            Self::Utf8(e) => {
                write!(f, "UTF-8 error: `{e}`")
            }
        }
    }
}