chiark / gitweb /
Display error body
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 17:02:30 +0000 (18:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 17:02:30 +0000 (18:02 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs

index a6cecb168373052ac7bc81bda71aa3d2e6432f5b..6236b4811c3dd34a627404f3342c2e0e7c09e631 100644 (file)
@@ -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;