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

Adding custom mapper for json processing exception #2264

Merged
merged 1 commit into from
Jan 22, 2016

Conversation

himank
Copy link

@himank himank commented Jan 14, 2016

Custom exception mapper to return bad request instead of returning 500.

{
return Response.status(Response.Status.BAD_REQUEST).entity(ImmutableMap.of("Error", arg0.getMessage())).build();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

missing newline

Copy link
Author

Choose a reason for hiding this comment

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

I'll add it thanks

@himank himank force-pushed the CustomExceptionMapper branch 2 times, most recently from 85585de to 2cb0631 Compare January 14, 2016 20:35
@himank
Copy link
Author

himank commented Jan 14, 2016

Updated the pull request with customizing JsonMappingException instead of JsonProcessingException as the former one is more appropriate for problems related to mapping content. Before/After output is below.

https://gist.github.com/himank/2bf076ab0b3b5c93c038

@fjy
Copy link
Contributor

fjy commented Jan 15, 2016

Thanks for the contrib @himank. Will try to review shortly

@himank
Copy link
Author

himank commented Jan 16, 2016

@fjy Thanks :)

@himank
Copy link
Author

himank commented Jan 20, 2016

@fjy If you get chance could you please review it, Thanks in advance.

public Response toResponse(JsonMappingException exception)
{
return Response.status(Response.Status.BAD_REQUEST)
.entity(ImmutableMap.of("Error", exception.getMessage()))
Copy link
Contributor

Choose a reason for hiding this comment

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

other places use "error" lower case

Copy link
Contributor

Choose a reason for hiding this comment

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

also should probably be exception.getMessage() == null ? "unknown json mapping exception" : exception.getMessage() or similar

@drcrallen
Copy link
Contributor

👍 after minor comments

@drcrallen
Copy link
Contributor

Thanks for the contrib @himank . Could you please fill out the CLA at http://druid.io/community/cla.html ?

@himank
Copy link
Author

himank commented Jan 22, 2016

@drcrallen Thanks for the review, updated as per your comments. Please review when you get chance :)

@fjy
Copy link
Contributor

fjy commented Jan 22, 2016

👍

xvrl added a commit that referenced this pull request Jan 22, 2016
Adding custom mapper for json processing exception
@xvrl xvrl merged commit 789b35a into apache:master Jan 22, 2016
@fjy
Copy link
Contributor

fjy commented Jan 23, 2016

@himank do you mind following the steps here? https://groups.google.com/forum/#!topic/druid-development/1Zs3Vd9LHCQ so your contribution will be counted :)

@fjy fjy added this to the 0.9.0 milestone Feb 4, 2016
@fjy fjy mentioned this pull request Feb 5, 2016
@fjy fjy added the Feature label Feb 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants