Skip to content

Commit

Permalink
feat: missing request cookie exception 핸들러 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
psychology50 committed Aug 13, 2024
1 parent d7da829 commit 26b3316
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingRequestCookieException;
import org.springframework.web.bind.MissingRequestHeaderException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
Expand Down Expand Up @@ -56,6 +57,21 @@ protected ResponseEntity<ErrorResponse> handleGlobalErrorException(GlobalErrorEx
return ResponseEntity.status(e.getBaseErrorCode().causedBy().statusCode().getCode()).body(response);
}

/**
* API 호출 시 'Cookie' 내에 데이터 값이 유효하지 않은 경우
*
* @see MissingRequestCookieException
*/
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MissingRequestCookieException.class)
@JsonView(CustomJsonView.Common.class)
protected ErrorResponse handleMissingRequestCookieException(MissingRequestCookieException e) {
log.warn("handleMissingRequestCookieException : {}", e.getMessage());
String code = String.valueOf(StatusCode.BAD_REQUEST.getCode() * 10 + ReasonCode.MISSING_REQUIRED_PARAMETER.getCode());

return ErrorResponse.of(code, e.getMessage());
}

/**
* API 호출 시 'Method' 내에 데이터 값이 유효하지 않은 경우
*
Expand Down

0 comments on commit 26b3316

Please sign in to comment.