From 3866c68e795c67225c59663bd0e84291512965f6 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Fri, 27 Jan 2017 11:35:23 -0600 Subject: [PATCH] Add check for status code on request, closes #60 --- bot.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bot.go b/bot.go index 7ae3b47..bf541a0 100644 --- a/bot.go +++ b/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