Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8 - Provide clearer error for non-200 status codes without JSON #19

Merged
merged 3 commits into from
Oct 16, 2018

Conversation

erutherford
Copy link
Contributor

@erutherford erutherford commented Aug 31, 2018

What

  • This adds a check for a non-200 status code if there's a failure to unmarshal the response from the server.
  • Added tests to confirm the current behavior of returning the first error in the index if it is able to parse the response.

#8

…about the status code if it was not 200

accounting for both paths where there might be a non-200 response
@erutherford
Copy link
Contributor Author

@dahernan is it possible you'd be able to take a look at this? I'm definitely open to suggestions on the PR, I was trying to maintain the current behavior, but account for errors where there isn't a JSON response with as little modification as possible.

@dahernan
Copy link
Contributor

Sorry I have no context for this, maybe @matryer could help

@matryer
Copy link
Contributor

matryer commented Sep 11, 2018 via email

@erutherford
Copy link
Contributor Author

I went based of the last couple merges, sorry for the incorrect ping. Thanks for checking out the PR and providing this client.

graphql.go Outdated
@@ -42,6 +42,8 @@ import (
"github.com/pkg/errors"
)

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like an unnecessary constant to me. Let's just duplicate the string for now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Great PR btw)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @matryer, I pulled the constant and duplicated the string.

@erutherford
Copy link
Contributor Author

Looks like it's failing because of this, updating my branch.
golang/lint#415

@matryer matryer merged commit 06f92ef into machinebox:master Oct 16, 2018
@matryer
Copy link
Contributor

matryer commented Oct 16, 2018

Thanks @erutherford, nice work.

@erutherford erutherford deleted the 8-check-status-code branch October 16, 2018 15:19
This was referenced Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants