Skip to content

Commit 9d8fab8

Browse files
committed
refactor: 에러 처리 로직 리팩토링
1 parent 90228d2 commit 9d8fab8

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

slidingwindowcounter.iml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
<module version="4">
33
<component name="AdditionalModuleElements">
44
<content url="file://$MODULE_DIR$" dumb="true">
5+
<excludeFolder url="file://$MODULE_DIR$/.idea/copilot" />
56
<excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
7+
<excludeFolder url="file://$MODULE_DIR$/.idea/modules" />
8+
<excludeFolder url="file://$MODULE_DIR$/.idea/sonarlint" />
69
</content>
710
</component>
811
<component name="SonarLintModuleSettings">

src/main/java/com/systemdesign/slidingwindowcounter/common/exception/CommonExceptionCode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public enum CommonExceptionCode implements ExceptionCode {
1414
COMMON_BAD_REQUEST(BAD_REQUEST, "COM-002", "잘못된 요청"),
1515
COMMON_METHOD_NOT_ALLOWED(METHOD_NOT_ALLOWED, "COM-003", "허용되지 않은 HTTP Method 요청 발생"),
1616
COMMON_INTERNAL_SERVER_ERROR(INTERNAL_SERVER_ERROR, "COM-004", "기타 서버 내부 에러 발생"),
17-
COMMON_TOO_MANY_REQUESTS(TOO_MANY_REQUESTS,"COM-005", "사용자 요청 횟수 초과"),
18-
;
17+
;
1918

2019
private final HttpStatus status;
2120
private final String code;

src/main/java/com/systemdesign/slidingwindowcounter/common/exception/GlobalExceptionHandler.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,4 @@ public ResponseEntity<ExceptionResponse> handleBusinessException(BusinessExcepti
4343
return ResponseEntity.status(exceptionCode.getStatus())
4444
.body(ExceptionResponse.from(exceptionCode.getCode()));
4545
}
46-
47-
@ExceptionHandler(RateLimitExceededException.class)
48-
public ResponseEntity<ExceptionResponse> handleRateLimitExceededException(RateLimitExceededException e) {
49-
return ResponseEntity.status(COMMON_TOO_MANY_REQUESTS.getStatus())
50-
.body(ExceptionResponse.from(COMMON_TOO_MANY_REQUESTS.getCode()));
51-
}
5246
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.systemdesign.slidingwindowcounter.exception;
2+
3+
import com.systemdesign.slidingwindowcounter.common.exception.ExceptionCode;
4+
import lombok.Getter;
5+
import lombok.RequiredArgsConstructor;
6+
import org.springframework.http.HttpStatus;
7+
8+
import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS;
9+
10+
@Getter
11+
@RequiredArgsConstructor
12+
public enum RateExceptionCode implements ExceptionCode {
13+
14+
COMMON_TOO_MANY_REQUESTS(TOO_MANY_REQUESTS, "RAT-001", "사용자 요청 횟수 초과"),
15+
;
16+
17+
private final HttpStatus status;
18+
private final String code;
19+
private final String message;
20+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
package com.systemdesign.slidingwindowcounter.common.exception;
1+
package com.systemdesign.slidingwindowcounter.exception;
2+
3+
import com.systemdesign.slidingwindowcounter.common.exception.BusinessException;
4+
import com.systemdesign.slidingwindowcounter.common.exception.ExceptionCode;
25

36
public class RateLimitExceededException extends BusinessException {
47

0 commit comments

Comments
 (0)