Skip to content

Commit

Permalink
Merge pull request #136 from studio-recoding/fix-discord-wrong-method
Browse files Browse the repository at this point in the history
[🔧fix] 디스코드 알림 중 HttpRequestMethodNotSupportedException은 알림에서 제외
  • Loading branch information
JeonHaeseung authored Jul 9, 2024
2 parents eb62130 + 5934662 commit a5e9d22
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -37,6 +38,14 @@ protected ResponseEntity<ErrorResponse> handleNoResourceFoundException(NoResourc
return new ResponseEntity<>(ErrorResponse.onFailure(ErrorCode._INTERNAL_SERVER_ERROR), null, INTERNAL_SERVER_ERROR);
}

// 잘못된 HTTP 메소드 요청 따로 처리(디스코드 알림에서 제외하기 위함)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
protected ResponseEntity<ErrorResponse> handleMethodNotSupportedException(HttpRequestMethodNotSupportedException httpRequestMethodNotSupportedException, HttpServletRequest httpServletRequest) {
log.error("handleMethodNotSupportedException", httpRequestMethodNotSupportedException);
final ContentCachingRequestWrapper contentCachingRequestWrapper = new ContentCachingRequestWrapper(httpServletRequest);
return new ResponseEntity<>(ErrorResponse.onFailure(ErrorCode._INTERNAL_SERVER_ERROR), null, INTERNAL_SERVER_ERROR);
}

// 따로 처리하지 않은 500 에러 모두 처리
@ExceptionHandler(Exception.class)
protected ResponseEntity<ErrorResponse> handleException(Exception exception, HttpServletRequest httpServletRequest) {
Expand Down

0 comments on commit a5e9d22

Please sign in to comment.