File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,11 @@ impl<S: Sleeper> AsyncClient<S> {
442442 Some ( height) => format ! ( "/blocks/{height}" ) ,
443443 None => "/blocks" . to_string ( ) ,
444444 } ;
445- self . get_response_json ( & path) . await
445+ let blocks: Vec < BlockSummary > = self . get_response_json ( & path) . await ?;
446+ if blocks. is_empty ( ) {
447+ return Err ( Error :: InvalidResponse ) ;
448+ }
449+ Ok ( blocks)
446450 }
447451
448452 /// Get the underlying base URL.
Original file line number Diff line number Diff line change @@ -370,7 +370,11 @@ impl BlockingClient {
370370 Some ( height) => format ! ( "/blocks/{}" , height) ,
371371 None => "/blocks" . to_string ( ) ,
372372 } ;
373- self . get_response_json ( & path)
373+ let blocks: Vec < BlockSummary > = self . get_response_json ( & path) ?;
374+ if blocks. is_empty ( ) {
375+ return Err ( Error :: InvalidResponse ) ;
376+ }
377+ Ok ( blocks)
374378 }
375379
376380 /// Sends a GET request to the given `url`, retrying failed attempts
Original file line number Diff line number Diff line change @@ -225,6 +225,8 @@ pub enum Error {
225225 InvalidHttpHeaderName ( String ) ,
226226 /// Invalid HTTP Header value specified
227227 InvalidHttpHeaderValue ( String ) ,
228+ /// The server sent an invalid response
229+ InvalidResponse ,
228230}
229231
230232impl fmt:: Display for Error {
You can’t perform that action at this time.
0 commit comments