Skip to content

Commit

Permalink
chore: 404 알림 제외 처리 (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
thdwoqor authored Nov 15, 2024
1 parent f470eae commit 93c9334
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public enum ExceptionCode {
INVALID_AUTHENTICATION_FORM(302, "올바른 인증 형식이 아닙니다."),

LOCK_CODE_EXCEPTION(501, "RedisLockTarget 파라미터를 찾을 수 없습니다."),
GETTING_LOCK_FAIL_EXCEPTION(502, "레디스 락을 얻는데 실패하였습니다.");
GETTING_LOCK_FAIL_EXCEPTION(502, "레디스 락을 얻는데 실패하였습니다."),

NO_STATIC_RESOURCE(404, "리소스를 찾을 수 없습니다.");

private final int code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package mafia.mafiatogether.common.exception;

import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import mafia.mafiatogether.common.application.ErrorNotificationService;
Expand All @@ -16,11 +20,7 @@
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import org.springframework.web.servlet.NoHandlerFoundException;

@Slf4j
@RestControllerAdvice
Expand All @@ -31,6 +31,16 @@ public class GlobalExceptionHandler {
private final ErrorNotificationService errorNotificationService;
private static final String LOCAL_PROFILE_NAME = "local";

@ExceptionHandler(NoHandlerFoundException.class)
public ResponseEntity<ErrorResponse> handleNoHandlerFoundException() {
final ErrorResponse errorResponse = ErrorResponse.create(
ExceptionCode.NO_STATIC_RESOURCE.getCode(),
"리소스를 찾을 수 없습니다."
);

return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorResponse);
}

@ExceptionHandler(Exception.class)
protected ResponseEntity<ErrorResponse> Exception(Exception e, HttpServletRequest request) {
final ErrorResponse errorResponse = ErrorResponse.create(
Expand Down

0 comments on commit 93c9334

Please sign in to comment.