I'm trying to match &dyn Error type to skip the logging.
I get the websock:151 Failed to recv message from ws: WebSocket protocol error: Connection reset without closing handshake
error in the log but my downcast_ref method fails and fails to catch this specific error. how am i supposed to catch the error appropriately?
while let Some(message) = ws_rx.next().await {
let msg = match message {
Ok(msg) => msg,
Err(e) => {
// ResetWithoutClosingHandshake just means that client has disconnected.
// Skip the logging and break the loop.
if let Some(e) = e.source() {
match e.downcast_ref::<tungstenite::error::Error>() {
Some(tungstenite::Error::Protocol(
ProtocolError::ResetWithoutClosingHandshake,
)) => break,
_ => (),
};
}
log_error!("Failed to recv message from ws: {e}");
continue;
}
};