Skip to content

Commit

Permalink
handle non-400 from ld
Browse files Browse the repository at this point in the history
  • Loading branch information
jazanne committed Aug 3, 2023
1 parent 54897e4 commit eb37172
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/ldclient/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ func getFlags(config *lcr.Config, params url.Values) ([]ldapi.FeatureFlag, error
return []ldapi.FeatureFlag{}, err
}
defer resp.Body.Close()
decoder := json.NewDecoder(resp.Body)

if resp.StatusCode != http.StatusOK {
var r interface{}
_ = decoder.Decode(&r)
err := fmt.Errorf("unexpected status code: %d with response: %#v", resp.StatusCode, r)
return nil, err
}

flags := ldapi.FeatureFlags{}
err = json.NewDecoder(resp.Body).Decode(&flags)
err = decoder.Decode(&flags)
if err != nil {
return []ldapi.FeatureFlag{}, err
}
Expand Down

0 comments on commit eb37172

Please sign in to comment.