ericafenyo / senior-hub-api

Backend REST API for the Senior Hub project with Spring Boot, Docker and MySQL
MIT License
0 stars 0 forks source link

HandlerMethodValidationException is not handled properly #3

Open ericafenyo opened 2 months ago

ericafenyo commented 2 months ago

The exception thrown is HandlerMethodValidationException when @NotBlank is declared directly on method parameters such as @PathVariable. However, we were expecting MethodArgumentNotValidException, which is currently handled, to return a custom error response.

ericafenyo commented 2 months ago

The spring docs explained they type of exception thrown during validation and proposed a way to handle each case.

https://docs.spring.io/spring-framework/reference/web/webmvc/mvc-controller/ann-validation.html