You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the quarkus app with some REST resouces and the following global Exception handling class:
class ExceptionHandler{
@ServerExceptionMapper
fun throwable(throwable: Throwable): Response {
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("").build()
}
}
if a POST request is executed with malformed request body that leads to com.fasterxml.jackson.databind.exc.MismatchedInputException, then the exception will not be matched here. I tried to set the method parameter type from Throwable to any super exception class of MismatchedInputException such as com.fasterxml.jackson.databind.JsonMappingException and com.fasterxml.jackson.databind.DatabindException, none of them works. It mathes only when the type is MismatchedInputException.
In the exception handling class, there can be multiple methods with annotation @ServerExceptionMapper and different exception types to have different handling and have the method with type Throwable as default exception handling. But it seems not work well.
Expected behavior
The method with Throwable type should match any exception type if there is no more specific matching.
Actual behavior
The method with Throwable cannot match more specific exception MismatchedInputException
How to Reproduce?
No response
Output of uname -a or ver
No response
Output of java -version
21
Quarkus version or git rev
3.11.2 for quarkus
Build tool (ie. output of mvnw --version or gradlew --version)
gradlew
Additional information
No response
The text was updated successfully, but these errors were encountered:
This is actually the expected behavior because Quarkus ships with an exception mapper for MismatchedInputException and the JAX-RS / Jakarta REST spec states that a more specific exception mapper takes precedence over a more general one.
Hi @geoand, thanks for your explanation. Now I understand the reason. Then in the app one need to find out all the implementations of ExceptionMapper if customizing the error response is required.
Describe the bug
Consider the quarkus app with some REST resouces and the following global Exception handling class:
if a POST request is executed with malformed request body that leads to
com.fasterxml.jackson.databind.exc.MismatchedInputException
, then the exception will not be matched here. I tried to set the method parameter type fromThrowable
to any super exception class ofMismatchedInputException
such ascom.fasterxml.jackson.databind.JsonMappingException
andcom.fasterxml.jackson.databind.DatabindException
, none of them works. It mathes only when the type isMismatchedInputException
.In the exception handling class, there can be multiple methods with annotation
@ServerExceptionMapper
and different exception types to have different handling and have the method with typeThrowable
as default exception handling. But it seems not work well.Expected behavior
The method with
Throwable
type should match any exception type if there is no more specific matching.Actual behavior
The method with
Throwable
cannot match more specific exceptionMismatchedInputException
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
21
Quarkus version or git rev
3.11.2 for quarkus
Build tool (ie. output of
mvnw --version
orgradlew --version
)gradlew
Additional information
No response
The text was updated successfully, but these errors were encountered: