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) }