return error when not 200 for GET method

pull/7/head
Yasuhiro Matsumoto 2017-04-14 17:37:50 +09:00
parent d1e98eb548
commit dd7163e01e
1 changed files with 5 additions and 0 deletions

View File

@ -47,6 +47,11 @@ func (c *Client) doAPI(method string, uri string, params url.Values, res interfa
if res == nil { if res == nil {
return nil return nil
} }
if method == "GET" && resp.StatusCode != 200 {
return fmt.Errorf("bad request: %v", resp.Status)
}
return json.NewDecoder(resp.Body).Decode(&res) return json.NewDecoder(resp.Body).Decode(&res)
} }