From e57167dd05742c35bd07c1e930c339d3cb36540a Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Thu, 11 Jul 2024 17:07:34 +1200 Subject: [PATCH] Swallow mild IO errors inside of Tungstenite errors --- src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e27e992..5300015 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,6 +189,23 @@ async fn handle_http_request( // No big deal, still SessionExit::Ok msg = "Reset"; } + ChorusError::Tungstenite(tungstenite::error::Error::Io( + ref ioerror, + )) => { + match ioerror.kind() { + std::io::ErrorKind::ConnectionReset | + std::io::ErrorKind::ConnectionAborted | + std::io::ErrorKind::UnexpectedEof => { + // no biggie. + msg = "Reset"; + } + _ => { + log::error!(target: "Client", "{}: {}", peer, e); + session_exit = SessionExit::ErrorExit; + msg = "Error Exited"; + } + } + } ChorusError::ErrorClose => { session_exit = SessionExit::TooManyErrors; msg = "Errored Out";