1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| @RestControllerAdvice @Slf4j public class exceptionHander {
@ExceptionHandler(BindException.class) public ReturnDto handleError(BindException e) { return ReturnDto.error(e.getBindingResult().getFieldError().getDefaultMessage()); }
@ExceptionHandler(ConstraintViolationException.class) public ReturnDto handleError(ConstraintViolationException e) { return ReturnDto.error(e.getMessage()); }
@ExceptionHandler(MethodArgumentNotValidException.class) public ReturnDto exceptionHandler(MethodArgumentNotValidException e) { return ReturnDto.error(e.getBindingResult().getFieldError().getDefaultMessage()); }
}
|