Skip to content

Commit

Permalink
Document how to turn off DefaultMismatchedInputException
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Sep 10, 2024
1 parent 7f09b8c commit 7a89863
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions docs/src/main/asciidoc/rest.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,28 @@ In both cases, importing those modules will allow HTTP message bodies to be read
and serialised to JSON, for <<resource-types,all the types not already registered with a more specific
serialisation>>.

==== Advanced Jackson-specific features
==== Jackson-specific features

When using the `quarkus-rest-jackson` extension there are some advanced features that Quarkus REST supports.
===== Exception handling

By default, Quarkus provides a built-in `ExceptionMapper` for `MismatchedInputException` which returns an HTTP 400 status code
along with a good error message in Dev and Test modes, about what went wrong during serialization of an entity.

[NOTE]
====
There are situations where various Jackson related exceptions need to handled in a uniform way.For example, the application may need to handle all `JsonMappingException` the same way.
This becomes a problem when taking JAX-RS / Jakarta REST rules into account, because the exception mapper `ExceptionMapper` for `MismatchedInputException` would be used instead of the user provide
`ExceptionMapper` for `JsonMappingException` (as `MismatchedInputException` is a subtype of `JsonMappingException`).
One solution for this case is to configure the following:
[source,properties]
----
quarkus.class-loading.removed-resources."io.quarkus\:quarkus-rest-jackson"=io/quarkus/resteasy/reactive/jackson/runtime/mappers/DefaultMismatchedInputException.class
----
which essentially makes Quarkus ignore the `ExceptionMapper` for `MismatchedInputException` completely.
====

[[secure-serialization]]
===== Secure serialization
Expand Down

0 comments on commit 7a89863

Please sign in to comment.