Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ func (c *Client) runWithJSON(ctx context.Context, req *Request, resp interface{}
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return fmt.Errorf("server returned a non-200 status code: %v", res.StatusCode)
return &HttpError{
err: fmt.Errorf("server returned a non-200 status code: %v", res.StatusCode),
Response: res,
}
}
var buf bytes.Buffer
if _, err := io.Copy(&buf, res.Body); err != nil {
Expand Down Expand Up @@ -317,6 +320,15 @@ type File struct {
R io.Reader
}

type HttpError struct {
err error
Response *http.Response
}

func (e *HttpError) Error() string {
return e.err.Error()
}

type GraphQLError struct {
err error
Message string
Expand Down