Improve error message when connecting

This commit is contained in:
Manfred Touron 2015-10-13 16:41:37 +02:00
parent ba7cead601
commit 217058435b
No known key found for this signature in database
GPG Key ID: 0DCB9CE0CABAE1B5
1 changed files with 7 additions and 0 deletions

View File

@ -108,6 +108,13 @@ func (c *Client) GetAuthToken() (string, error) {
return "", err
}
switch resp.StatusCode {
case 200:
// Everything is OK
default:
return "", fmt.Errorf("unknown status code: %d (%s)", resp.StatusCode, http.StatusText(resp.StatusCode))
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {