I think the answer you are looking for is registering a custom
WebApplicationException mapper...
@Provider
public class CustomWebApplicationExceptionMapper implements
ExceptionMapper<WebApplicationException>
{
public Response toResponse(WebApplicationException ex)
{
if ( ex.cause() instanceOf java.lang.NumberFormatException )
{
return Response.status(400).entity("Should have used a
number!").build();
}
else { ... some default response instead .... }
}
}
then in your spring bean file make sure to register it...
<jaxrs:server ..... >
<jaxrs:provider>
<ref bean="customWebApplicationExceptionMapper"/>
</jaxrs:provider>
....
</jaxrs:server/>
<bean id="customWebApplicationExceptionMapper"
class="CustomWebApplicationExceptionMapper"/>
--
View this message in context: http://jersey.576304.n2.nabble.com/How-to-catch-the-response-in-case-of-an-invalid-query-paramter-tp6272285p6345730.html
Sent from the Jersey mailing list archive at Nabble.com.