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
@cowtowncoder
I have implemented JavaAgent (with ByteBuddy) which transforms classes to support executable validation for methods and constructors parametres on non-CDI beans (but just plain POJOs) as a result when a REST endpoint receives body and tries to deserialize JSON to Object using setter or constructor
(for example)
So it sees ConstraintViolationException but wraps it with JsonMappingException obviously.
How to tell Jackson to not to throw JsonMappingException if the cause is ConstraintViolationException?
Is it possible to allow jackson to Unwrap / Do Not Wrap the cause it?
Hibernate Validator framework will, as well implement and provide default implementation of Executable Validation (maybe even in 6.x version soon). They already started to implement here are the starters, so the problem will occur as well.
P.S. Maybe it is worth to just allow for the whole library overall to check if the cause is ConstraintViolationException and rethrow if so ?
I use version 2.9.5 (and 2.8.9 - which behaves the same)
The text was updated successfully, but these errors were encountered:
@soberich It is possible to disable exception wrapping (for cases where possible) using WRAP_EXCEPTIONS for both DeserializationFeature and SerializationFeature. That applies to all RuntimeExceptions; by default IOExceptions are not wrapped by default.
I don't think I want to start adding specialized handling for all potential subtypes of RuntimeException.
It could be possible to consider some sort of pluggable handler that could determine what to do (not wrap; wrap with some other legal exception), although that would need to be for Jackson 3.0.
One thing to consider is that many libraries and frameworks wrap exceptions, so calling code tends to have ability to "unwrap" exceptions to find root causes. That may be better way to go here.
Not quite sure how to proceed with this, closing: may be reopened with more concrete proposal (like proposing some sort of handler to decide whether to wrap an exception(s) of some type).
@cowtowncoder
I have implemented JavaAgent (with ByteBuddy) which transforms classes to support executable validation for methods and constructors parametres on non-CDI beans (but just plain POJOs) as a result when a REST endpoint receives body and tries to deserialize JSON to Object using setter or constructor
(for example)
if constraint violation occur, I got ..
So it sees
ConstraintViolationException
but wraps it withJsonMappingException
obviously.How to tell Jackson to not to throw JsonMappingException if the cause is
ConstraintViolationException
?Is it possible to allow jackson to Unwrap / Do Not Wrap the cause it?
Hibernate Validator framework will, as well implement and provide default implementation of Executable Validation (maybe even in 6.x version soon). They already started to implement here are the starters, so the problem will occur as well.
P.S. Maybe it is worth to just allow for the whole library overall to check if the cause is ConstraintViolationException and rethrow if so ?
I use version 2.9.5 (and 2.8.9 - which behaves the same)
The text was updated successfully, but these errors were encountered: