Skip to content

Add support for custom Jackson JsonMappingException exception mapper #36155

@danifalconr24

Description

@danifalconr24

Describe the bug

Using Quarkus 2.16.10.Final

Hello,

The issue im having is that im not able to provide custom exception mappers for exceptions like ValueInstantiationException or even better would be being able to provide a mapper for JsonMappingException which is a more generic type, but, this mappers are getting ignored, because in the case of ValueInstantiationException the exception is getting mapped to a WebApplicationException by the resteasy reactive jackson quarkus extension, another example could be the InvalidFormatException which is not getting mapped into a WebApplicationException but the only way to override the default exception mapper is to provide an specific mapper for this exception, it could be much better if we can just create a mapper for JsonMappingException and handle all this Jackson exceptions directly there because they all extend from this exception.

Expected behavior

Support the possibility to provide a JsonMappingException and get all this exceptions that extends from this one

Actual behavior

Handle every exception differently, anď map them to WebApplicationException.

How to Reproduce?

Reproduce:

ValueInstantiationException

1 -> have some endpoint that receives an object with any enum property
2 -> request with invalid enum value
3 -> ValueInstantiationException is mapped somewhere to a WebApplicationException

InvalidFormatException

1 -> have some endpoint that receives an object with an Integer property
2 -> request with a string that cannot be mapped to an Integer. ie: "abcd"
3 -> We cannot handle this exception inside the JsonMappingException mapper because there is a more specific exception mapper provided by Jackson library

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/jacksonIssues related to Jackson (JSON library)kind/bugSomething isn't workingtriage/needs-reproducerWe are waiting for a reproducer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions