Skip to content

Commit

Permalink
[#38] feat: 쿠키 예외처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hsik0225 committed Jun 5, 2020
1 parent 5bc3255 commit 04bc656
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@
@RestControllerAdvice
public class GlobalRestExceptionHandler {

@ExceptionHandler(IllegalStateException.class)
protected ResponseEntity<ErrorResponse> handleIllegalStateException(IllegalStateException e) {
log.error("handleIllegalStateException", e);
final ErrorResponse response = ErrorResponse.of(e.getMessage(), HttpStatus.FORBIDDEN.value());
return new ResponseEntity<>(response, HttpStatus.FORBIDDEN);
}

@ExceptionHandler(IllegalReservationDateException.class)
protected ResponseEntity<ErrorResponse> IllegalReservationDateException(IllegalReservationDateException e) {
protected ResponseEntity<ErrorResponse> handleIllegalReservationDateException(IllegalReservationDateException e) {
log.error("handleIllegalReservationDateException", e);
final ErrorResponse response = ErrorResponse.of(e.getMessage(), HttpStatus.BAD_REQUEST.value());

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Confirmation showBillAndReview(@RequestParam Long roomId, @Valid Reservat
public ResponseEntity<HttpStatus> reserve(@RequestParam Long roomId,
@Valid ReservationDate reservationDate,
@Valid Guest guest,
HttpServletRequest request) {
@CookieValue(value = "jwt")) {

Long id = (Long) request.getAttribute("id");
boolean canReserve = managerDAO.canReserve(roomId, reservationDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public RoomDetail mapRow(ResultSet rs, int rowNum) throws SQLException {
price,
medias,
rs.getString("host"),
managerDAO.canReserve(rs.getLong("id"), checkInDate, checkOutDate)
managerDAO.canReserve(rs.getLong("id"), reservationDate)
);
}
};
Expand Down

0 comments on commit 04bc656

Please sign in to comment.