@@ -65,48 +65,34 @@ pub enum WebSocketOtherError {
65
65
impl fmt:: Display for WebSocketOtherError {
66
66
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
67
67
match self {
68
- WebSocketOtherError :: RequestError ( e) => write ! ( fmt, "WebSocket request error: {}" , e) ? ,
68
+ WebSocketOtherError :: RequestError ( e) => write ! ( fmt, "WebSocket request error: {}" , e) ,
69
69
WebSocketOtherError :: ResponseError ( e) => {
70
- write ! ( fmt, "WebSocket response error: {}" , e) ?
70
+ write ! ( fmt, "WebSocket response error: {}" , e)
71
71
}
72
72
WebSocketOtherError :: StatusCodeError ( e) => write ! (
73
73
fmt,
74
74
"WebSocketError: Received unexpected status code ({})" ,
75
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) ? ,
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
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( ) ) ?,
82
+ WebSocketOtherError :: TlsError ( e) => write ! ( fmt, "WebSocket SSL error: {}" , e) ,
83
+ WebSocketOtherError :: ProtocolError ( e) => write ! ( fmt, "WebSocketError: {}" , e) ,
84
+ WebSocketOtherError :: TlsHandshakeFailure => {
85
+ write ! ( fmt, "WebSocketError: {}" , "TLS Handshake failure" )
86
+ }
87
+ WebSocketOtherError :: TlsHandshakeInterruption => {
88
+ write ! ( fmt, "WebSocketError: {}" , "TLS Handshake interrupted" )
89
+ }
84
90
}
85
- Ok ( ( ) )
86
91
}
87
92
}
88
93
89
94
impl Error for WebSocketOtherError {
90
- fn description ( & self ) -> & str {
91
- match * self {
92
- WebSocketOtherError :: RequestError ( _) => "WebSocket request error" ,
93
- WebSocketOtherError :: ResponseError ( _) => "WebSocket response error" ,
94
- WebSocketOtherError :: HttpError ( _) => "HTTP failure" ,
95
- WebSocketOtherError :: UrlError ( _) => "URL failure" ,
96
- #[ cfg( any( feature = "sync-ssl" , feature = "async-ssl" ) ) ]
97
- WebSocketOtherError :: TlsError ( _) => "TLS failure" ,
98
- #[ cfg( any( feature = "sync-ssl" , feature = "async-ssl" ) ) ]
99
- WebSocketOtherError :: TlsHandshakeFailure => "TLS Handshake failure" ,
100
- #[ cfg( any( feature = "sync-ssl" , feature = "async-ssl" ) ) ]
101
- WebSocketOtherError :: TlsHandshakeInterruption => "TLS Handshake interrupted" ,
102
- WebSocketOtherError :: WebSocketUrlError ( _) => "WebSocket URL failure" ,
103
- WebSocketOtherError :: IoError ( ref e) => e. description ( ) ,
104
- WebSocketOtherError :: ProtocolError ( e) => e,
105
- WebSocketOtherError :: StatusCodeError ( _) => "Received unexpected status code" ,
106
- }
107
- }
108
-
109
- fn cause ( & self ) -> Option < & dyn Error > {
95
+ fn source ( & self ) -> Option < & ( dyn Error + ' static ) > {
110
96
match * self {
111
97
WebSocketOtherError :: HttpError ( ref error) => Some ( error) ,
112
98
WebSocketOtherError :: UrlError ( ref error) => Some ( error) ,
@@ -197,21 +183,16 @@ pub enum WSUrlErrorKind {
197
183
impl fmt:: Display for WSUrlErrorKind {
198
184
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
199
185
fmt. write_str ( "WebSocket Url Error: " ) ?;
200
- fmt. write_str ( self . description ( ) ) ?;
201
- Ok ( ( ) )
202
- }
203
- }
204
-
205
- impl Error for WSUrlErrorKind {
206
- fn description ( & self ) -> & str {
207
- match * self {
208
- WSUrlErrorKind :: CannotSetFragment => "WebSocket URL cannot set fragment" ,
209
- WSUrlErrorKind :: InvalidScheme => "WebSocket URL invalid scheme" ,
210
- WSUrlErrorKind :: NoHostName => "WebSocket URL no host name provided" ,
186
+ match self {
187
+ WSUrlErrorKind :: CannotSetFragment => fmt. write_str ( "WebSocket URL cannot set fragment" ) ,
188
+ WSUrlErrorKind :: InvalidScheme => fmt. write_str ( "WebSocket URL invalid scheme" ) ,
189
+ WSUrlErrorKind :: NoHostName => fmt. write_str ( "WebSocket URL no host name provided" ) ,
211
190
}
212
191
}
213
192
}
214
193
194
+ impl Error for WSUrlErrorKind { }
195
+
215
196
impl From < WebSocketOtherError > for WebSocketError {
216
197
fn from ( e : WebSocketOtherError ) -> WebSocketError {
217
198
WebSocketError :: Other ( Box :: new ( e) )
0 commit comments