Given that MethodArgumentNotValidException
extends BindException
, after #23107, we can now use the former instead of the latter for an @ModelAttribute
arguments. It is a more specific exception, which helps to provide method parameter details, and it aligns with @RequestBody
and will simplify default exception handling a bit.
In addition, with the support for RFC 7807 in #27052 (and related issues), web exceptions now encapsulate error response details, and expose message codes for external control of the detail description, see #28814. This makes it even more useful to raise the MethodArgumentNotValidException
sub-class.