Skip to content

Handle responses with status codes > 300 but with body returned #15

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

Closed
wants to merge 4 commits into from

Conversation

hubertlepicki
Copy link

Hey,

I have a web service that returns error messages in response body (JSON) as well as using HTTP response codes. For example, when user account fails to be created, I return 422 with JSON content { errors: { password: ["is too short!"]}}. I needed to handle those responses, and added such functioanlity to your library.

Please let me know if that's any good or welcome addition, or what should I improve.

@scottanderson
Copy link

I would prefer to see an added String parameter to onFailure() to pass down the message. You could have the default implementation call the old onFailure(Throwable) (which should be @deprecated and eventually removed) to preserve compatibility with old code.

This would eliminate the need to subclass the HttpResponseException class, lightening the amount of junk in permgen -- although I'm not sure how much that matters in a library that encourages the use of anonymous classes.

Also note that you can squash/fixup your commits to make the diff easier to read. If you push --force them to the same branch the pull request is operating on, github will automatically update the pull request. http://book.git-scm.com/4_interactive_rebasing.html

@loopj
Copy link
Collaborator

loopj commented Mar 27, 2012

I agree with @scottanderson's comments

@loopj
Copy link
Collaborator

loopj commented Oct 30, 2012

onFailure calls now contain the error body

@loopj loopj closed this Oct 30, 2012
@korkag korkag mentioned this pull request Sep 8, 2014
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