File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -68,8 +68,8 @@ pub enum Error {
6868 ParsingError ( serde_json:: error:: Error ) ,
6969
7070 /// Could not connect to server
71- #[ error( "Server unavailable" ) ]
72- ServerUnavailable ,
71+ #[ error( "Server unavailable: {0} " ) ]
72+ ServerUnavailable ( String ) ,
7373
7474 /// Could not determine signer scheme
7575 #[ error( "Couldn't choose signing scheme" ) ]
Original file line number Diff line number Diff line change @@ -16,16 +16,22 @@ impl HyperExt for hyper::Response<hyper::body::Body> {
1616 where
1717 T : de:: DeserializeOwned ,
1818 {
19- if !self . status ( ) . is_success ( ) {
20- log:: error!( "Server responded with error" ) ;
21- return Err ( Error :: ServerUnavailable ) ;
22- }
23- let ( _, body) = self . into_parts ( ) ;
19+ let ( parts, body) = self . into_parts ( ) ;
2420 let body = hyper:: body:: to_bytes ( body)
2521 . await
2622 . map_err ( Error :: ConnectionError ) ?;
27- let token = serde_json:: from_slice ( & body) . map_err ( Error :: ParsingError ) ?;
2823
24+ if !parts. status . is_success ( ) {
25+ let error = format ! (
26+ "Server responded with error {}: {}" ,
27+ parts. status,
28+ String :: from_utf8_lossy( body. as_ref( ) )
29+ ) ;
30+ log:: error!( "{}" , error) ;
31+ return Err ( Error :: ServerUnavailable ( error) ) ;
32+ }
33+
34+ let token = serde_json:: from_slice ( & body) . map_err ( Error :: ParsingError ) ?;
2935 Ok ( token)
3036 }
3137}
You can’t perform that action at this time.
0 commit comments