Skip to content

Commit

Permalink
Better error for feature flags fetch without errors. Adds missing for…
Browse files Browse the repository at this point in the history
…mat string verbs to poller Errorf.
  • Loading branch information
mkraft committed Aug 8, 2024
1 parent 96410d9 commit 08e5855
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions featureflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,23 @@ func (poller *FeatureFlagsPoller) fetchNewFeatureFlags() {
res, cancel, err := poller.localEvaluationFlags(headers)
defer cancel()
if err != nil || res.StatusCode != http.StatusOK {
poller.Errorf("Unable to fetch feature flags", err)
if err != nil {
poller.Errorf("Unable to fetch feature flags: %s", err)
} else {
poller.Errorf("Unable to fetch feature flags, status: %s", res.Status)
}
return
}
defer res.Body.Close()
resBody, err := ioutil.ReadAll(res.Body)
if err != nil {
poller.Errorf("Unable to fetch feature flags", err)
poller.Errorf("Unable to fetch feature flags: %s", err)
return
}
featureFlagsResponse := FeatureFlagsResponse{}
err = json.Unmarshal([]byte(resBody), &featureFlagsResponse)
if err != nil {
poller.Errorf("Unable to unmarshal response from api/feature_flag/local_evaluation", err)
poller.Errorf("Unable to unmarshal response from api/feature_flag/local_evaluation: %s", err)
return
}
newFlags := []FeatureFlag{}
Expand Down

0 comments on commit 08e5855

Please sign in to comment.