Add check for status code on request, closes #60
parent
3293f3ad84
commit
3866c68e79
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)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return APIResponse{}, errors.New(http.StatusText(resp.StatusCode))
|
||||
}
|
||||
|
||||
bytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return APIResponse{}, err
|
||||
|
|
Loading…
Reference in New Issue