diff --git a/src/main/java/com/dnd/snappy/common/error/CommonErrorCode.java b/src/main/java/com/dnd/snappy/common/error/CommonErrorCode.java index 875266a..d612e3d 100644 --- a/src/main/java/com/dnd/snappy/common/error/CommonErrorCode.java +++ b/src/main/java/com/dnd/snappy/common/error/CommonErrorCode.java @@ -12,7 +12,7 @@ public enum CommonErrorCode implements ErrorCodeInterface { DUPLICATION(HttpStatus.CONFLICT, "COMMON_DUPLICATION", "중복된 리소스가 존재합니다."), VALIDATION_ERROR(HttpStatus.BAD_REQUEST, "VALIDATION_ERROR", "유효성 검사 실패했습니다."), - DATA_TIME_PARSE_ERROR(HttpStatus.BAD_REQUEST, "DATA_TIME_PARSE_ERROR", "요청된 시간을 파싱할 수 없습니다."), + INVALID_REQUEST(HttpStatus.BAD_REQUEST, "INVALID_REQUEST", "요청 형식에 맞지 않는 요청입니다. api 문서를 다시 확인해 주세요."), INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR", "알 수 없는 에러") ; diff --git a/src/main/java/com/dnd/snappy/common/error/GlobalExceptionHandler.java b/src/main/java/com/dnd/snappy/common/error/GlobalExceptionHandler.java index 70c5b7e..d93af60 100644 --- a/src/main/java/com/dnd/snappy/common/error/GlobalExceptionHandler.java +++ b/src/main/java/com/dnd/snappy/common/error/GlobalExceptionHandler.java @@ -8,6 +8,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -56,15 +57,15 @@ protected ResponseEntity> handleMethodArgumentNotValidException( return ResponseDto.fail(errorCode); } - @ExceptionHandler(DateTimeParseException.class) - protected ResponseEntity> handleDateTimeParseException( - final DateTimeParseException e, + @ExceptionHandler(HttpMessageNotReadableException.class) + protected ResponseEntity> handleHttpMessageNotReadableException( + final HttpMessageNotReadableException e, final HttpServletRequest request ) { - ErrorCode errorCode = CommonErrorCode.DATA_TIME_PARSE_ERROR.toErrorCode(); + ErrorCode errorCode = CommonErrorCode.INVALID_REQUEST.toErrorCode(); errorCode.appendMessage(e.getMessage()); - log.info("DateTimeParseException: {} {}", e.getMessage(), request.getRequestURL(), e); + log.info("HttpMessageNotReadableException: {} {}", e.getMessage(), request.getRequestURL(), e); return ResponseDto.fail(errorCode); }