From f160a9b37d3dbe54574761de1fbc9f5b2128b31c Mon Sep 17 00:00:00 2001 From: Jordan Noone Date: Sat, 29 Aug 2026 16:08:34 -0700 Subject: [PATCH] Surface API response bodies on errors --- src/cmd_api.rs | 7 ++++++- src/tests.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd_api.rs b/src/cmd_api.rs index 4183098a..3e27ccb7 100644 --- a/src/cmd_api.rs +++ b/src/cmd_api.rs @@ -189,7 +189,12 @@ impl crate::cmd::Command for CmdApi { } if !status.is_success() { - return Err(anyhow!("{} {}", status, status.canonical_reason().unwrap_or(""))); + let body = resp.text().await?; + return Err(if body.is_empty() { + anyhow!("{status}") + } else { + anyhow!("{status}: {body}") + }); } if self.paginate { diff --git a/src/tests.rs b/src/tests.rs index 8791b42f..cab3a99e 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -520,7 +520,7 @@ cli_tests! { svec!["zoo", "api", "foo/bar"], ) .setup(setup_authenticated) - .stderr_contains("404 Not Found Not Found") + .stderr_contains("404 Not Found:") .exit_code(1) }