Skip to content

Commit

Permalink
feat: 필수 이미지가 들어오지 않는 경우 해당하는 예외 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
Curry4182 committed Apr 29, 2024
1 parent 045732f commit c2272aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.multipart.support.MissingServletRequestPartException;

import com.programmers.lime.error.BusinessException;
import com.programmers.lime.error.EntityNotFoundException;
Expand Down Expand Up @@ -94,6 +95,15 @@ public ResponseEntity<ErrorResponse> handleMultipartException(final MultipartExc
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(MissingServletRequestPartException.class)
public ResponseEntity<ErrorResponse> handleMissingServletRequestPartException(
final MissingServletRequestPartException e) {
log.info("MissingServletRequestPartException", e);
final ErrorResponse response = ErrorResponse.from(ErrorCode.MISSING_REQUEST_IMAGE);

return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(HttpMessageNotReadableException.class)
public ResponseEntity<ErrorResponse> handleHttpMessageNotReadableException(
final HttpMessageNotReadableException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum ErrorCode {
INVALID_ACCESSOR("COMMON_020", "잘못된 Accessor 입니다."),
UNSUPPORTED_IMAGE_TYPE("COMMON_021", "업로드 할 수 있는 이미지 확장자가 아닙니다."),
NOT_CONVERTIBLE_IMAGE("COMMON_022", "이미지 변환에 실패했습니다."),
MISSING_REQUEST_IMAGE("COMMON_023", "하나 이상의 이미지를 업로드 해야합니다"),

// Member
MEMBER_LOGIN_FAIL("MEMBER_001", "로그인 정보가 잘못 되었습니다."),
Expand Down

0 comments on commit c2272aa

Please sign in to comment.