As I understand it, a malformed @QueryParam will return a 404 with no message. For
example, localhost:8080/api/v1/users?number_param=123 will respond with 404. Apparently,
this is due to the JAX-RS spec:
```
3.2 Fields and Bean Properties
if the field or property is annotated with @MatrixParam, @QueryParam or @PathParam then an
implementation MUST generate an instance of NotFoundException (404 status) that wraps the
thrown exception and no entity
```
I would like the modify this behavior to:
1. Return a 400 status code, as I believe 404 causes confusion for users (they will think
the endpoint doesn't exist)
2. Show a helpful error message, for example "'123' is an invalid input for
number_param, expected number"
I have read that the way to do this is with the ExceptionMapper<E extends Throwable>
interface. Is this true? And if so, which Exception E should I use? Is there something
like a QueryParamException?
If it matters, I am using RESTEasy with Quarkus.
Thanks,
Arwin
Show replies by thread