cli: surface HTTP status and body on backend errors
All checks were successful
CI / Backend (pull_request) Successful in 32s
CI / CLI (pull_request) Successful in 10s

This commit is contained in:
2026-05-25 17:18:31 +00:00
parent 35fb17f888
commit 2b1c26781e
2 changed files with 21 additions and 1 deletions

View File

@@ -59,6 +59,11 @@ def save_response(response: httpx.Response, destination: Path) -> None:
destination.write_bytes(response.content)
def format_http_error(response: httpx.Response, endpoint: str) -> str:
body = response.text.strip() or "<empty response body>"
return f"HTTP {response.status_code} from {endpoint}: {body}"
def main() -> int:
parser = build_parser()
args = parser.parse_args()
@@ -84,7 +89,7 @@ def main() -> int:
try:
response.raise_for_status()
except httpx.HTTPStatusError as exc:
message = exc.response.text.strip() or str(exc)
message = format_http_error(exc.response, endpoint)
parser.exit(1, f"{message}\n")
if args.to_file: