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

when SG returns error, library happily returns success #50

Closed
kanekv opened this issue Nov 26, 2019 · 5 comments · Fixed by #57
Closed

when SG returns error, library happily returns success #50

kanekv opened this issue Nov 26, 2019 · 5 comments · Fixed by #57

Comments

@kanekv
Copy link

kanekv commented Nov 26, 2019

Hey @gsquire, I've tried to send message and it returned Ok with the following error:

{"errors":[{"message":"If present, text/plain must be first, followed by text/html, followed by any other content.","field":"content","help":null}]}

I wonder if SG returns successful status code in this case?

@kanekv
Copy link
Author

kanekv commented Nov 26, 2019

Did a quick check and SG does return 400. I think it would make sense to check if response anything else than 200 and return an error instead.

@kanekv
Copy link
Author

kanekv commented Nov 26, 2019

Let me know how you want to approach this and I might provide a PR.

@gsquire
Copy link
Owner

gsquire commented Nov 26, 2019

Hey, Kane. I didn't do any status checking so I would be happy to integrate that in.

@kanekv
Copy link
Author

kanekv commented Nov 26, 2019

@gsquire main question do we return response text verbatim or try to decode json?

@gsquire
Copy link
Owner

gsquire commented Nov 26, 2019

Perhaps we can make a new error type for unsuccessful responses and return that? So you could parse the JSON and return the actual status.

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 a pull request may close this issue.

2 participants