HTRACE-310. htracedTool: when there is an error response, print the body of the response (Colin Patrick McCabe via iwasakims)
diff --git a/htrace-htraced/go/src/org/apache/htrace/client/client.go b/htrace-htraced/go/src/org/apache/htrace/client/client.go
index 0028545..65b04e4 100644
--- a/htrace-htraced/go/src/org/apache/htrace/client/client.go
+++ b/htrace-htraced/go/src/org/apache/htrace/client/client.go
@@ -225,14 +225,14 @@
 			err.Error()))
 	}
 	defer resp.Body.Close()
+	body, err2 := ioutil.ReadAll(resp.Body)
+	if err2 != nil {
+		return nil, -1, errors.New(fmt.Sprintf("Error: error reading response body: %s\n", err2.Error()))
+	}
 	if resp.StatusCode != http.StatusOK {
 		return nil, resp.StatusCode,
-			errors.New(fmt.Sprintf("Error: got bad response status from %s: %s\n", url, resp.Status))
-	}
-	var body []byte
-	body, err = ioutil.ReadAll(resp.Body)
-	if err != nil {
-		return nil, -1, errors.New(fmt.Sprintf("Error: error reading response body: %s\n", err.Error()))
+			errors.New(fmt.Sprintf("Error: got bad response status from " +
+				"%s: %s\n%s\n", url, resp.Status, body))
 	}
 	return body, 0, nil
 }