Skip to content

Commit e4a5269

Browse files
committed
refactor: 오류 로그해결
1 parent df2742d commit e4a5269

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/store/lastdance/exception/GlobalExceptionHandler.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public ResponseEntity<ErrorResponseDTO> handleMethodArgumentNotValidException(
100100

101101
@ExceptionHandler(RuntimeException.class)
102102
public ResponseEntity<ErrorResponseDTO> handleRuntimeException(RuntimeException e, WebRequest request) {
103+
if (e instanceof org.springframework.security.core.AuthenticationException || e instanceof org.springframework.security.access.AccessDeniedException) {
104+
throw e; // Re-throw to let Spring Security handle it
105+
}
103106
log.error("RuntimeException occurred: {}", e.getMessage(), e);
104107

105108
ErrorResponseDTO errorResponseDTO = ErrorResponseDTO.builder()
@@ -113,7 +116,10 @@ public ResponseEntity<ErrorResponseDTO> handleRuntimeException(RuntimeException
113116
}
114117

115118
@ExceptionHandler(Exception.class)
116-
public ResponseEntity<ErrorResponseDTO> handleGeneralException(Exception e, WebRequest request) {
119+
public ResponseEntity<ErrorResponseDTO> handleGeneralException(Exception e, WebRequest request) throws Exception {
120+
if (e instanceof org.springframework.security.core.AuthenticationException || e instanceof org.springframework.security.access.AccessDeniedException) {
121+
throw e;
122+
}
117123
log.error("Unexpected exception occurred: {}", e.getMessage(), e);
118124

119125
ErrorResponseDTO errorResponseDTO = ErrorResponseDTO.builder()

0 commit comments

Comments
 (0)