Skip to content
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

Use MethodArgumentNotValidException for model attribute arguments #29251

Closed
Tracked by #28814
rstoyanchev opened this issue Oct 4, 2022 · 0 comments
Closed
Tracked by #28814

Use MethodArgumentNotValidException for model attribute arguments #29251

rstoyanchev opened this issue Oct 4, 2022 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@rstoyanchev
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant