Raise MethodArgumentNotValidException consistently

Closes gh-30100
This commit is contained in:
rstoyanchev
2023-03-14 09:08:29 +00:00
parent e17f5c50a8
commit d18bcb3f3d
2 changed files with 13 additions and 11 deletions

View File

@@ -174,7 +174,7 @@ public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResol
}
validateIfApplicable(binder, parameter);
if (binder.getBindingResult().hasErrors() && isBindExceptionRequired(binder, parameter)) {
throw new BindException(binder.getBindingResult());
throw new MethodArgumentNotValidException(parameter, binder.getBindingResult());
}
}
// Value type adaptation, also covering java.util.Optional