users@jersey.java.net

QueryParamException and 404 vs 400 responses

From: Tim McCune <tmccune_at_yahoo-inc.com>
Date: Thu, 17 Jun 2010 11:50:31 -0700

According to the Javadocs for URIParamException at
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/ParamException.URIParamException.html
"All such exceptions of this type will contain a response with a 404
(Not Found) status code."
QueryParamException is one of those subclasses. Say I have a resource
with a @QueryParam of type Integer, and the user passes a non-integer
value in that query param (e.g. /myResource?myParam=a). Jersey will
respond with a 404.

I suppose I can see how a QueryParamException returning a 404 error
might make sense in some scenarios, but wouldn't returning a 400 error
make more sense in pretty much any scenario where the parameter value
can't be coerced into the declared data type?