Description
Affects: 6.1.x or higher
I have been migrating from AOP method validation via @Validated
to Spring MVC built-in method validation, added in 6.1, for queryString variable with @Constraint
annotations on my controller. I have noticed that there is no simple way to extract the cause of newly thrown HandlerMethodValidationException
when replacing old handler method for ConstraintViolationException
.
Despite the fact that document describes HandlerMethodValidationException
is "very similar" to the good old
MethodArgumentNotValidException,
it lacks of the way to extract the source, ConstraintViolation
while with MethodArgumentNotValidException
from validating @RequestBody
, you could get simply get it through ObjectError
or FieldError
in the exception.
HandlerMethodValidationException
from validating queryString only contains DefaultMessageSourceResolvable
. I think if it contains some kind of "ViolationParameterError
" or something just like MethodArgumentNotValidException
, it would be great to have unifying handler method for any validation exceptions from controller layer.