Skip to content

Commit 0d8c5d2

Browse files
authored
Merge pull request #249 from Enet4/imp/websocketothererror_display
2 parents e9a3c9c + e861d69 commit 0d8c5d2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/result.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,24 @@ pub enum WebSocketOtherError {
6464

6565
impl fmt::Display for WebSocketOtherError {
6666
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
67-
fmt.write_str("WebSocketError: ")?;
68-
fmt.write_str(self.description())?;
67+
match self {
68+
WebSocketOtherError::RequestError(e) => write!(fmt, "WebSocket request error: {}", e)?,
69+
WebSocketOtherError::ResponseError(e) => {
70+
write!(fmt, "WebSocket response error: {}", e)?
71+
}
72+
WebSocketOtherError::StatusCodeError(e) => write!(
73+
fmt,
74+
"WebSocketError: Received unexpected status code ({})",
75+
e
76+
)?,
77+
WebSocketOtherError::HttpError(e) => write!(fmt, "WebSocket HTTP error: {}", e)?,
78+
WebSocketOtherError::UrlError(e) => write!(fmt, "WebSocket URL parse error: {}", e)?,
79+
WebSocketOtherError::IoError(e) => write!(fmt, "WebSocket I/O error: {}", e)?,
80+
WebSocketOtherError::WebSocketUrlError(e) => e.fmt(fmt)?,
81+
#[cfg(any(feature = "sync-ssl", feature = "async-ssl"))]
82+
WebSocketOtherError::TlsError(e) => write!(fmt, "WebSocket SSL error: {}", e)?,
83+
_ => write!(fmt, "WebSocketError: {}", self.description())?,
84+
}
6985
Ok(())
7086
}
7187
}

0 commit comments

Comments
 (0)