Skip to content

Commit

Permalink
removing the constant and opting for duplicating the string
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Rutherford committed Oct 15, 2018
1 parent 9835de6 commit 6a25cc3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ import (
"github.com/pkg/errors"
)

const errorNon200Template = "graphql: server returned a non-200 status code: %v"

// Client is a client for interacting with a GraphQL API.
type Client struct {
endpoint string
Expand Down Expand Up @@ -137,7 +135,7 @@ func (c *Client) runWithJSON(ctx context.Context, req *Request, resp interface{}
c.logf("<< %s", buf.String())
if err := json.NewDecoder(&buf).Decode(&gr); err != nil {
if res.StatusCode != http.StatusOK {
return fmt.Errorf(errorNon200Template, res.StatusCode)
return fmt.Errorf("graphql: server returned a non-200 status code: %v", res.StatusCode)
}
return errors.Wrap(err, "decoding response")
}
Expand Down Expand Up @@ -207,7 +205,7 @@ func (c *Client) runWithPostFields(ctx context.Context, req *Request, resp inter
c.logf("<< %s", buf.String())
if err := json.NewDecoder(&buf).Decode(&gr); err != nil {
if res.StatusCode != http.StatusOK {
return fmt.Errorf(errorNon200Template, res.StatusCode)
return fmt.Errorf("graphql: server returned a non-200 status code: %v", res.StatusCode)
}
return errors.Wrap(err, "decoding response")
}
Expand Down

0 comments on commit 6a25cc3

Please sign in to comment.