1
1
//! Error and Result module.
2
+
3
+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
4
+ use crate :: client:: connect:: Connected ;
2
5
use std:: error:: Error as StdError ;
3
6
use std:: fmt;
4
7
@@ -15,6 +18,8 @@ pub struct Error {
15
18
struct ErrorImpl {
16
19
kind : Kind ,
17
20
cause : Option < Cause > ,
21
+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
22
+ connect_info : Option < Connected > ,
18
23
}
19
24
20
25
#[ derive( Debug ) ]
@@ -210,9 +215,20 @@ impl Error {
210
215
self . inner . cause
211
216
}
212
217
218
+ /// Returns the info of the client connection on which this error occurred.
219
+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
220
+ pub fn client_connect_info ( & self ) -> Option < & Connected > {
221
+ self . inner . connect_info . as_ref ( )
222
+ }
223
+
213
224
pub ( super ) fn new ( kind : Kind ) -> Error {
214
225
Error {
215
- inner : Box :: new ( ErrorImpl { kind, cause : None } ) ,
226
+ inner : Box :: new ( ErrorImpl {
227
+ kind,
228
+ cause : None ,
229
+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
230
+ connect_info : None ,
231
+ } ) ,
216
232
}
217
233
}
218
234
@@ -221,6 +237,12 @@ impl Error {
221
237
self
222
238
}
223
239
240
+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
241
+ pub ( super ) fn with_client_connect_info ( mut self , connect_info : Connected ) -> Error {
242
+ self . inner . connect_info = Some ( connect_info) ;
243
+ self
244
+ }
245
+
224
246
#[ cfg( any( all( feature = "http1" , feature = "server" ) , feature = "ffi" ) ) ]
225
247
pub ( super ) fn kind ( & self ) -> & Kind {
226
248
& self . inner . kind
0 commit comments