Log error if Heroku API req responds with non-200-range code

pull/2911/head
Jared Scheib 2018-03-02 17:15:47 -06:00
parent 32632f5790
commit 03e966a44a
1 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package oauth2
import (
"encoding/json"
"fmt"
"net/http"
"github.com/influxdata/chronograf"
@ -65,6 +66,15 @@ func (h *Heroku) PrincipalID(provider *http.Client) (string, error) {
// Requests fail to Heroku unless this Accept header is set.
req.Header.Set("Accept", "application/vnd.heroku+json; version=3")
resp, err := provider.Do(req)
if resp.StatusCode/100 != 2 {
err := fmt.Errorf(
"Unable to GET user data from %s. Status: %s",
HerokuAccountRoute,
resp.Status,
)
h.Logger.Error("", err)
return "", err
}
if err != nil {
h.Logger.Error("Unable to communicate with Heroku. err:", err)
return "", err