users@jersey.java.net

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

From: DirkM <dirk_at_olx.com>
Date: Tue, 18 Aug 2009 08:52:04 -0500 (CDT)

Paul Sandoz wrote:
>
> I have fixed this in the trunk:
>

Fantastic, thanks!


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)


Paul Sandoz wrote:
>
> I think we should also review other WebApplicationException thrown by
> the runtime and classify them.
>

Sounds like a good idea as well.

Thanks again,
Dirk

-- 
View this message in context: http://n2.nabble.com/Why-do-IllegalArgumentExceptions-cause-a-404-instead-of-a-400--tp3447019p3466164.html
Sent from the Jersey mailing list archive at Nabble.com.