Add check for status code on request, closes #60

bot-api-6.1
Syfaro 2017-01-27 11:35:23 -06:00
parent 3293f3ad84
commit 3866c68e79
1 changed files with 4 additions and 0 deletions

4
bot.go
View File

@ -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