Skip to content

Commit

Permalink
Fix Spring 3.2.2 migration (#1586)
Browse files Browse the repository at this point in the history
HandlerMethodValidationException is thrown in some validations instead MethodArgumentNotValidException
handle it also

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Feb 2, 2024
1 parent 94ed1f8 commit 7a7fb7f
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -31,6 +31,7 @@
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.method.annotation.HandlerMethodValidationException;
import org.springframework.web.multipart.MultipartException;

import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -164,7 +165,10 @@ public ResponseEntity<Object> handleFileStreamingFailedException(final HttpServl
* @return the entity to be responded containing the exception information
* as entity.
*/
@ExceptionHandler({ HttpMessageNotReadableException.class, MethodArgumentNotValidException.class, IllegalArgumentException.class })
@ExceptionHandler({
HttpMessageNotReadableException.class,
MethodArgumentNotValidException.class, HandlerMethodValidationException.class,
IllegalArgumentException.class })
public ResponseEntity<ExceptionInfo> handleExceptionCausedByIncorrectRequestBody(final HttpServletRequest request,
final Exception ex) {
logRequest(request, ex);
Expand Down

0 comments on commit 7a7fb7f

Please sign in to comment.