From cb5e9065d34ce7e4c3f7458cf2a5b670f3acb559 Mon Sep 17 00:00:00 2001 From: Caleb Leinz Date: Wed, 11 Dec 2024 10:38:23 -0800 Subject: [PATCH] feat: Client errors on non-success status --- src/client.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/client.rs b/src/client.rs index 31495a0..2be8763 100644 --- a/src/client.rs +++ b/src/client.rs @@ -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)) }