From 1d331f0707eaa4a056aa6261410fb1edb63097b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 30 Mar 2021 16:15:53 +0200 Subject: report tcp errors all the way --- mumd/src/error.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'mumd/src/error.rs') diff --git a/mumd/src/error.rs b/mumd/src/error.rs index e4a8fee..142e806 100644 --- a/mumd/src/error.rs +++ b/mumd/src/error.rs @@ -12,6 +12,21 @@ pub enum TcpError { IOError(std::io::Error), } +impl fmt::Display for TcpError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + TcpError::NoConnectionInfoReceived + => write!(f, "No connection info received"), + TcpError::TlsConnectorBuilderError(e) + => write!(f, "Error building TLS connector: {}", e), + TcpError::TlsConnectError(e) + => write!(f, "TLS error when connecting: {}", e), + TcpError::SendError(e) => write!(f, "Couldn't send packet: {}", e), + TcpError::IOError(e) => write!(f, "IO error: {}", e), + } + } +} + impl From for TcpError { fn from(e: std::io::Error) -> Self { TcpError::IOError(e) @@ -37,6 +52,18 @@ impl From for UdpError { } } +pub enum ClientError { + TcpError(TcpError), +} + +impl fmt::Display for ClientError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ClientError::TcpError(e) => write!(f, "TCP error: {}", e), + } + } +} + pub enum AudioStream { Input, Output, @@ -96,4 +123,3 @@ impl fmt::Display for StateError { } } } - -- cgit v1.2.1