Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ impl<S: Sleeper> AsyncClient<S> {
Some(height) => format!("/blocks/{height}"),
None => "/blocks".to_string(),
};
self.get_response_json(&path).await
let blocks: Vec<BlockSummary> = self.get_response_json(&path).await?;
if blocks.is_empty() {
return Err(Error::InvalidResponse);
}
Ok(blocks)
}

/// Get the underlying base URL.
Expand Down
6 changes: 5 additions & 1 deletion src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ impl BlockingClient {
Some(height) => format!("/blocks/{}", height),
None => "/blocks".to_string(),
};
self.get_response_json(&path)
let blocks: Vec<BlockSummary> = self.get_response_json(&path)?;
if blocks.is_empty() {
return Err(Error::InvalidResponse);
}
Ok(blocks)
}

/// Sends a GET request to the given `url`, retrying failed attempts
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ pub enum Error {
InvalidHttpHeaderName(String),
/// Invalid HTTP Header value specified
InvalidHttpHeaderValue(String),
/// The server sent an invalid response
InvalidResponse,
}

impl fmt::Display for Error {
Expand Down
Loading