use crate::{SessionId, secio::error::SecioError};
use multiaddr::Multiaddr;
use std::io::Error as IOError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum TransportErrorKind {
#[error("transport io error: `{0:?}`")]
Io(#[from] IOError),
#[error("proxy error: `{0:?}`")]
ProxyError(IOError),
#[error("multiaddr `{0:?}` is not supported")]
NotSupported(Multiaddr),
#[error("can not resolve `{0:?}`, io error: `{1:?}`")]
DnsResolverError(Multiaddr, IOError),
#[error("tls setting error: `{0:?}`")]
#[cfg(feature = "tls")]
TlsError(String),
}
#[derive(Error, Debug)]
pub enum ProtocolHandleErrorKind {
#[error("protocol handle abnormally closed, session id: `{0:?}`")]
AbnormallyClosed(Option<SessionId>),
}
#[derive(Error, Debug)]
pub enum DialerErrorKind {
#[error("dialler io error: `{0:?}`")]
IoError(IOError),
#[error("peer id not match")]
PeerIdNotMatch,
#[error("repeated connection, sessio id: `{0:?}`")]
RepeatedConnection(SessionId),
#[error("handshake error: `{0:?}`")]
HandshakeError(HandshakeErrorKind),
#[error("transport error: `{0:?}`")]
TransportError(TransportErrorKind),
}
#[derive(Error, Debug)]
pub enum HandshakeErrorKind {
#[error("timeout error: `{0:?}`")]
Timeout(String),
#[error("secio error: `{0:?}`")]
SecioError(SecioError),
}
#[derive(Error, Debug)]
pub enum ListenErrorKind {
#[error("listen io error: `{0:?}`")]
IoError(IOError),
#[error("repeated connection, sessio id: `{0:?}`")]
RepeatedConnection(SessionId),
#[error("transport error: `{0:?}`")]
TransportError(TransportErrorKind),
}
#[derive(Error, Debug)]
pub enum SendErrorKind {
#[error("broken pipe")]
BrokenPipe,
#[error("would block")]
WouldBlock,
}