1@ControllerAdvice
2public class RestErrorHandler extends ResponseEntityExceptionHandler {
3
4 @Override
5 protected ResponseEntity<Object> handleMethodArgumentNotValid(
6 MethodArgumentNotValidException exception,
7 HttpHeaders headers,
8 HttpStatus status,
9 WebRequest request) {
10
11 LOG.error(exception);
12 String bodyOfResponse = exception.getMessage();
13 return new ResponseEntity(errorMessage, headers, status);
14 }
15}