users@jersey.java.net

Re: [Jersey] Why do IllegalArgumentExceptions cause a 404 instead of a 400?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 18 Aug 2009 16:32:56 +0200

On Aug 18, 2009, at 3:52 PM, DirkM wrote:
> Paul Sandoz wrote:
>>
>> So you can do this:
>>
>> public class MyQueryParamMapper implements
>> ExceptionMapper<QueryParamException> {
>> public Response toResponse(QueryParamException ex) {
>> return
>> Response.fromResponse(ex.getResponse()).status(400).build();
>> }
>> }
>>
>
> That makes much more sense. I agree that catching
> IllegalArgumentException
> is ambiguous at best.
>
> I would suggest using Response.Status.BAD_REQUEST instead of
> hardcoding 400
> (although realistically it's never going to change so it doesn't
> matter that
> much)
>

Good point though, i will change it.

Paul.