Change API to return error on 500 http status.

- The Telegram API does not return well-formed JSON when there is an 
Internal Server Error. This results in incomprehensible errors.
pull/14/head
Cedric Chin 9 years ago
parent 5db9cc7c56
commit f7c3d4f9d2

@ -74,6 +74,10 @@ func sendFile(method, token, name, path string, params url.Values) ([]byte, erro
return []byte{}, err
}
if resp.StatusCode == http.StatusInternalServerError {
return []byte{}, fmt.Errorf("Telegram API returned 500 internal server error")
}
json, err := ioutil.ReadAll(resp.Body)
if err != nil {
return []byte{}, err

Loading…
Cancel
Save