Skip to content

Commit fd011b9

Browse files
committed
feat: 필수 쿼리 파라미터가 없을 경우 에러 처리 구현
1 parent 3cc44ca commit fd011b9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/java/timeeat/exception/EtcErrorCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public enum EtcErrorCode {
1313
MEDIA_TYPE_NOT_SUPPORTED("CLIENT005", "허용되지 않은 미디어 타입입니다.", HttpStatus.UNSUPPORTED_MEDIA_TYPE),
1414
NO_RESOURCE_FOUND("CLIENT006", "요청한 리소스를 찾을 수 없습니다.", HttpStatus.NOT_FOUND),
1515
NO_COOKIE_FOUND("CLIENT007", "필수 쿠키 값이 존재하지 않습니다.", HttpStatus.BAD_REQUEST),
16-
NO_HEADER_FOUND("CLIENT007", "필수 헤더 값이 존재하지 않습니다.", HttpStatus.BAD_REQUEST),
16+
NO_HEADER_FOUND("CLIENT008", "필수 헤더 값이 존재하지 않습니다.", HttpStatus.BAD_REQUEST),
17+
NO_PARAMETER_FOUND("CLIENT009", "필수 파라미터 값이 존재하지 않습니다.", HttpStatus.BAD_REQUEST),
1718

1819
INTERNAL_SERVER_ERROR("SERVER001", "서버 내부 에러가 발생했습니다.", HttpStatus.INTERNAL_SERVER_ERROR),
1920
;

src/main/java/timeeat/exception/GlobalExceptionHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.springframework.web.HttpRequestMethodNotSupportedException;
1010
import org.springframework.web.bind.MissingRequestCookieException;
1111
import org.springframework.web.bind.MissingRequestHeaderException;
12+
import org.springframework.web.bind.MissingServletRequestParameterException;
1213
import org.springframework.web.bind.annotation.ExceptionHandler;
1314
import org.springframework.web.bind.annotation.RestControllerAdvice;
1415
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
@@ -68,6 +69,12 @@ public ResponseEntity<ErrorResponse> handleMissingRequestHeaderException(Missing
6869
return toErrorResponse(EtcErrorCode.NO_HEADER_FOUND);
6970
}
7071

72+
@ExceptionHandler(MissingServletRequestParameterException.class)
73+
public ResponseEntity<ErrorResponse> handleMissingServletRequestParameterException(
74+
MissingServletRequestParameterException exception) {
75+
return toErrorResponse(EtcErrorCode.NO_PARAMETER_FOUND);
76+
}
77+
7178
@ExceptionHandler(BusinessException.class)
7279
public ResponseEntity<ErrorResponse> handleBusinessException(BusinessException exception) {
7380
ErrorResponse response = new ErrorResponse(exception.getErrorCode());

0 commit comments

Comments
 (0)