Skip to content

Commit

Permalink
refactor: 각 도메인 동일한 예외 형식을 유지하도록 ErrorCode 인터페이스 도입
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeHanEum committed Feb 17, 2025
1 parent cb4d478 commit b8a7699
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/main/java/depromeet/onepiece/common/error/ErrorCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package depromeet.onepiece.common.error;

import org.springframework.http.HttpStatus;

public interface ErrorCode {
HttpStatus getStatus();

String getCode();

String getMessage();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@Getter
@AllArgsConstructor
public enum GlobalErrorCode {
public enum GlobalErrorCode implements ErrorCode {
// 공통
SUCCESS(HttpStatus.OK, "G000", "요청에 성공했습니다."),
OTHER(HttpStatus.INTERNAL_SERVER_ERROR, "G100", "서버에 오류가 발생했습니다"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
public class GlobalException extends RuntimeException {
@Getter private final GlobalErrorCode errorCode;

public GlobalException(String message, GlobalErrorCode errorCode) {
public GlobalException(String message, ErrorCode errorCode) {
super(message);
this.errorCode = errorCode;
this.errorCode = (GlobalErrorCode) errorCode;
}
}

0 comments on commit b8a7699

Please sign in to comment.