-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom Jackson JsonMappingException exception mapper #36155
Comments
Thanks a lot for reporting the issue. Would you mind attaching a sample application that behaves as you have described? Asking because I would like to see how this is different from what #29661 addressed. |
Closing as we never got feedback |
Hey @geoand @gsmet Could we please reopen this issue? I have an app sample here that shows the problem: |
@krismatusiak looking at your sample I am not sure I understand the problem |
@geoand Thanks for looking so fast ;) I appreciate that :) The challenge is to make all the tests pass ;) So the problem is this: I want to customize the status code (and such) when the JsonMappingException is thrown, and I cannot do that now. You provided a good solution for a similar case of the MismatchedInputException: this can be caught in the hanlders (= yeey). |
Thanks for explanations! So IIUC, you are seeing what is described in #41479. Can you try adding: quarkus.class-loading.removed-resources."io.quarkus\:quarkus-rest-jackson"=io/quarkus/resteasy/reactive/jackson/runtime/mappers/DefaultMismatchedInputException.class What that does is to disable the Quarkus' built-in exception mapper for |
Hey @geoand, Yes indeed, this is just like #41479 That said, the customization of the response code should be made to be easy, regardless. And now for the adding of quarkus.class-loading.removed-resources."io.quarkus:quarkus-rest-jackson"=io/quarkus/resteasy/reactive/jackson/runtime/mappers/DefaultMismatchedInputException.class So: IntelliJ does not like. It keeps reformatting this: cutting the 'key' off and adding more and more equal signs in the 'value', for some reason, in its configuration UI. So that does not fly there, regardless, even if its something werid on Intellij env var UI side. (vide screenshot one) In the commandline, however, I do get to pass it along. And so there: not only does the one failing test not pass, but also other tests are failing now. It is possible that I am not passing the var correctly or Im making a typo of some kind? I cannot see it. (vide screenshot two) |
#43126 should make things better (I used a sample application to verify) |
Ok, got it. Would you consider simplifying this (perhaps in addition to this property) into an easily-named boolean flag?
or some kind of list: |
Yeah, that's definitely up for discussion :) |
Lets discuss ;) What would make most sense for everyone and not add too much complexity? |
I'm on the fence. WDYT @gsmet ? |
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
orver
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
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: