When RESTEasy gets an exception while converting resource method argument annotated with some @Param annotation, it should return either 400 or 404 depending on which annotation is used. Instead, it currently always rethrows exception wrapped in BadRequestException, which always results in 400. (Unless exception is already WebApplicationException.)
See specification section "3.2 Fields and Bean Properties":
A WebApplicationException thrown during construction of field or property values using any of the
5 steps listed above is processed directly as described in Section 3.3.4. Other exceptions thrown during
construction of field or property values using any of the 5 steps listed above are treated as client errors: 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; if the field or property is annotated with @HeaderParam or @CookieParam then an implementation
MUST generate an instance of BadRequestException (400 status) that wraps the thrown exception and
no entity.
Although this section mentions fields and bean properties, it also applies to resource methods as stated in "3.3.2 Parameters":
Exceptions thrown during construction of parameter values are treated the same as exceptions thrown during construction of field or bean property values, see Section 3.2.
Bonus points:
Furthermore, it would be really nice if said exception was first subject to exception mapping, if there's an ExceptionMapper defined for it.
- relates to
-
RESTEASY-2189 (3.x) Incorrect status code when failed to parse some @*Param value
- Resolved
-
RESTEASY-2562 Incorrect status code when WebApplicationException is thrown while parsing @*Param
- Resolved
-
RESTEASY-1505 @DefaultValue on @PathParameter not working
- Open
-
RESTEASY-2177 Replace org.jboss.resteasy.spi.BadRequestException with javax.ws.rs.BadRequestException and org.jboss.resteasy.spi.NotFoundException with javax.ws.rs.NotFoundException
- Resolved