aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/error.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-03-30 16:15:53 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-03-30 16:15:53 +0200
commit1d331f0707eaa4a056aa6261410fb1edb63097b7 (patch)
tree3beca0c239306bd1ed6f9ee792abd5a855e190f7 /mumd/src/error.rs
parent79702d18bbd23df2faf0c00b0d9537ce26508f6b (diff)
downloadmum-1d331f0707eaa4a056aa6261410fb1edb63097b7.tar.gz
report tcp errors all the way
Diffstat (limited to 'mumd/src/error.rs')
-rw-r--r--mumd/src/error.rs28
1 files changed, 27 insertions, 1 deletions
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<std::io::Error> for TcpError {
fn from(e: std::io::Error) -> Self {
TcpError::IOError(e)
@@ -37,6 +52,18 @@ impl From<std::io::Error> 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 {
}
}
}
-