htrace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iwasak...@apache.org
Subject incubator-htrace git commit: HTRACE-310. htracedTool: when there is an error response, print the body of the response (Colin Patrick McCabe via iwasakims)
Date Sun, 29 Nov 2015 16:06:17 GMT
Repository: incubator-htrace
Updated Branches:
  refs/heads/master 3b10cfb53 -> f2c2ef157


HTRACE-310. htracedTool: when there is an error response, print the body of the response (Colin
Patrick McCabe via iwasakims)


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/f2c2ef15
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/f2c2ef15
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/f2c2ef15

Branch: refs/heads/master
Commit: f2c2ef157e8122377e60fb44e77fadf76d255162
Parents: 3b10cfb
Author: Masatake Iwasaki <iwasakims@apache.org>
Authored: Sat Nov 28 10:13:00 2015 +0900
Committer: Masatake Iwasaki <iwasakims@apache.org>
Committed: Sat Nov 28 10:13:00 2015 +0900

----------------------------------------------------------------------
 .../go/src/org/apache/htrace/client/client.go           | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/f2c2ef15/htrace-htraced/go/src/org/apache/htrace/client/client.go
----------------------------------------------------------------------
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 @@ func (hcl *Client) makeRestRequest(reqType string, reqName string,
 			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
 }


Mime
View raw message