From 5a57870d808f1601d85a35d08429b9ae19dafe93 Mon Sep 17 00:00:00 2001
From: Niall Sheridan <nsheridan@gmail.com>
Date: Fri, 22 Apr 2016 22:05:40 +0100
Subject: [PATCH] Check the error before trying to read the response.

---
 client/main.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/main.go b/client/main.go
index 10a3646b..c5f28f9c 100644
--- a/client/main.go
+++ b/client/main.go
@@ -46,12 +46,12 @@ func send(s []byte, token string) (*lib.SignResponse, error) {
 	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
 	client := &http.Client{}
 	resp, err := client.Do(req)
-	if resp.StatusCode != http.StatusOK {
-		return nil, fmt.Errorf("Bad response from server: %s", resp.Status)
-	}
 	if err != nil {
 		return nil, err
 	}
+	if resp.StatusCode != http.StatusOK {
+		return nil, fmt.Errorf("Bad response from server: %s", resp.Status)
+	}
 	defer resp.Body.Close()
 	body, err := ioutil.ReadAll(resp.Body)
 	if err != nil {
-- 
GitLab