I\'m using Jersey\'s integrated Jackson processing to transform incoming JSON to a POJO, e.g.:
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response newCus
I tried mapping status 500 to status 400 with HolySamosa's answer but the exception was not caught by this mapper, and status 500 was still being returned.
After debugging I found that JsonParseException is being thrown and not UnrecognizedPropertyException. This is because I was sending some garbage text (that was not JSON at all).
When I sent a proper JSON from client side, with format that was not appropriate for my DTO on the server side, then I got UnrecognizedPropertyException. So there are two cases for this:
Now I am returning status 400 for both.