From 5a57870d808f1601d85a35d08429b9ae19dafe93 Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Fri, 22 Apr 2016 22:05:40 +0100 Subject: Check the error before trying to read the response. --- client/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/main.go b/client/main.go index 10a3646..c5f28f9 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 { -- cgit v1.2.3