File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ pub enum Error {
5050 #[ error( "Hyper error" ) ]
5151 HyperError ( #[ from] Arc < hyper:: Error > ) ,
5252
53+ /// Connection dropped
54+ #[ error( "Connection dropped unexpectedly" ) ]
55+ ConnectionDropped ,
56+
5357 #[ error( "Invalid header value" ) ]
5458 InvalidHeaderError ,
5559
@@ -457,14 +461,18 @@ where
457461
458462 let ( mut sender, conn) = hyper:: client:: conn:: http1:: handshake ( tokio_io) . await ?;
459463
460- tokio:: task:: spawn ( async move {
461- if let Err ( err) = conn. await {
462- println ! ( "Connection failed: {:?}" , err) ;
464+ let response = tokio:: select! {
465+ res = sender. send_request( self . request) => res. map_err( Error :: from) ,
466+ conn_res = conn => {
467+ log:: error!( "API request connection failed" ) ;
468+ match conn_res {
469+ Ok ( ( ) ) => Err ( Error :: ConnectionDropped ) ,
470+ Err ( err) => Err ( Error :: HyperError ( Arc :: new( err) ) ) ,
471+ }
463472 }
464- } ) ;
473+ } ;
465474
466475 // Make request to hyper client
467- let response = sender. send_request ( self . request ) . await . map_err ( Error :: from) ;
468476
469477 // Notify access token store of expired tokens
470478 if let ( Some ( account) , Some ( store) ) = ( & self . account , & self . access_token_store ) {
You can’t perform that action at this time.
0 commit comments