Add check for status code on request, closes #60
This commit is contained in:
parent
3293f3ad84
commit
3866c68e79
1 changed files with 4 additions and 0 deletions
4
bot.go
4
bot.go
|
@ -68,6 +68,10 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse,
|
||||||
return APIResponse{}, errors.New(ErrAPIForbidden)
|
return APIResponse{}, errors.New(ErrAPIForbidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return APIResponse{}, errors.New(http.StatusText(resp.StatusCode))
|
||||||
|
}
|
||||||
|
|
||||||
bytes, err := ioutil.ReadAll(resp.Body)
|
bytes, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return APIResponse{}, err
|
return APIResponse{}, err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue