diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-04-22 22:05:40 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-04-22 23:16:11 +0100 |
commit | 5a57870d808f1601d85a35d08429b9ae19dafe93 (patch) | |
tree | 79e52899196cb611130474d644b54d33fec37fb2 | |
parent | 5e951c17cc1566df8655232708d56021fd8b796b (diff) |
Check the error before trying to read the response.
-rw-r--r-- | client/main.go | 6 |
1 files changed, 3 insertions, 3 deletions
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 { |