openlegends_client/connection/
error.rs1use std::fmt::{Display, Formatter, Result};
2
3#[derive(Debug)]
4pub enum Error {
5 TcpStream(std::io::Error),
6 TlsConnector(native_tls::Error),
7 TlsConnection(native_tls::HandshakeError<std::net::TcpStream>),
8 Utf8(std::str::Utf8Error),
9}
10
11impl Display for Error {
12 fn fmt(&self, f: &mut Formatter) -> Result {
13 match self {
14 Self::TcpStream(e) => {
15 write!(f, "TCP error: `{e}`")
16 }
17 Self::TlsConnector(e) => {
18 write!(f, "TLS error: `{e}`")
19 }
20 Self::TlsConnection(e) => {
21 write!(f, "Connection error: `{e}`")
22 }
23 Self::Utf8(e) => {
24 write!(f, "UTF-8 error: `{e}`")
25 }
26 }
27 }
28}