From dd7163e01ee3b7c76f57af73a944d7090c3bf847 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 14 Apr 2017 17:37:50 +0900 Subject: [PATCH] return error when not 200 for GET method --- mastodon.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mastodon.go b/mastodon.go index 50ba8a9..28dbfd4 100644 --- a/mastodon.go +++ b/mastodon.go @@ -47,6 +47,11 @@ func (c *Client) doAPI(method string, uri string, params url.Values, res interfa if res == nil { return nil } + + if method == "GET" && resp.StatusCode != 200 { + return fmt.Errorf("bad request: %v", resp.Status) + } + return json.NewDecoder(resp.Body).Decode(&res) }