11//! Error and Result module.
2+
3+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
4+ use crate :: client:: connect:: Connected ;
25use std:: error:: Error as StdError ;
36use std:: fmt;
47
@@ -15,6 +18,8 @@ pub struct Error {
1518struct ErrorImpl {
1619 kind : Kind ,
1720 cause : Option < Cause > ,
21+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
22+ connect_info : Option < Connected > ,
1823}
1924
2025#[ derive( Debug ) ]
@@ -206,9 +211,20 @@ impl Error {
206211 self . inner . cause
207212 }
208213
214+ /// Returns the info of the client connection on which this error occurred.
215+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
216+ pub fn client_connect_info ( & self ) -> Option < & Connected > {
217+ self . inner . connect_info . as_ref ( )
218+ }
219+
209220 pub ( super ) fn new ( kind : Kind ) -> Error {
210221 Error {
211- inner : Box :: new ( ErrorImpl { kind, cause : None } ) ,
222+ inner : Box :: new ( ErrorImpl {
223+ kind,
224+ cause : None ,
225+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
226+ connect_info : None ,
227+ } ) ,
212228 }
213229 }
214230
@@ -217,6 +233,12 @@ impl Error {
217233 self
218234 }
219235
236+ #[ cfg( all( feature = "client" , any( feature = "http1" , feature = "http2" ) ) ) ]
237+ pub ( super ) fn with_client_connect_info ( mut self , connect_info : Connected ) -> Error {
238+ self . inner . connect_info = Some ( connect_info) ;
239+ self
240+ }
241+
220242 #[ cfg( any( all( feature = "http1" , feature = "server" ) , feature = "ffi" ) ) ]
221243 pub ( super ) fn kind ( & self ) -> & Kind {
222244 & self . inner . kind
0 commit comments