From: Ian Jackson Date: Sun, 1 Aug 2021 17:02:30 +0000 (+0100) Subject: Display error body X-Git-Tag: hippotat/1.0.0~403 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=a7f0bb7a0047180b75d2906e86b4ee3ee98675d3;p=hippotat.git Display error body Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index a6cecb1..6236b48 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -91,14 +91,18 @@ fn submit_request<'r, 'c:'r, C:HCC>( let fut = Box::pin(async move { let r = async { tokio::time::timeout( c.ic.http_timeout, async { let resp = resp.await.context("make request")?; - if ! resp.status().is_success() { - throw!(anyhow!("HTTP error status {}", &resp.status())); - } + let status = resp.status(); let resp = resp.into_body(); // xxx: some size limit to avoid mallocing the universe let resp = hyper::body::to_bytes(resp).await .context("HTTP error fetching response body")?; + if ! status.is_success() { + // xxx get body and log it + throw!(anyhow!("HTTP error status={} body={:?}", + &status, String::from_utf8_lossy(&resp))); + } + Ok::<_,AE>(resp) }).await? }.await;