Skip to content

Commit

Permalink
feat: Client errors on non-success status
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-leinz committed Dec 11, 2024
1 parent 269faa9 commit cb5e906
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ impl Api for Client {

let status = resp.status();
let body = resp.bytes().await?;

if !status.is_success() {
let readable_body = String::from_utf8_lossy(&body);
return Err(crate::error::Error::Response(format!(
"{}\n{readable_body}",
status
)));
}

Ok((body, status))
}

Expand Down

0 comments on commit cb5e906

Please sign in to comment.