From 7eac74967fab5a262cdf2ca0986641b630d02be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9D=80=EB=B9=84?= <69096886+eunbc@users.noreply.github.com> Date: Mon, 8 Jan 2024 10:59:25 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20CustomException=EC=9D=98=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20BaseErrorCode=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(#155)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: CustomException의 필드를 BaseErrorCode로 변경 * fix: BaseErrorCode 수정 --- .../java/com/pgms/apimember/exception/CustomException.java | 6 +++--- .../pgms/apimember/exception/GlobalExceptionHandler.java | 3 ++- .../com/pgms/coredomain/domain/common/BaseErrorCode.java | 6 ++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/api/api-member/src/main/java/com/pgms/apimember/exception/CustomException.java b/api/api-member/src/main/java/com/pgms/apimember/exception/CustomException.java index 12e46709..38f7322b 100644 --- a/api/api-member/src/main/java/com/pgms/apimember/exception/CustomException.java +++ b/api/api-member/src/main/java/com/pgms/apimember/exception/CustomException.java @@ -1,15 +1,15 @@ package com.pgms.apimember.exception; -import com.pgms.coredomain.domain.common.MemberErrorCode; +import com.pgms.coredomain.domain.common.BaseErrorCode; import lombok.Getter; @Getter public class CustomException extends RuntimeException { - protected final MemberErrorCode errorCode; + protected final BaseErrorCode errorCode; - public CustomException(MemberErrorCode errorCode) { + public CustomException(BaseErrorCode errorCode) { super(errorCode.getMessage()); this.errorCode = errorCode; } diff --git a/api/api-member/src/main/java/com/pgms/apimember/exception/GlobalExceptionHandler.java b/api/api-member/src/main/java/com/pgms/apimember/exception/GlobalExceptionHandler.java index 08d86b3c..f22c1117 100644 --- a/api/api-member/src/main/java/com/pgms/apimember/exception/GlobalExceptionHandler.java +++ b/api/api-member/src/main/java/com/pgms/apimember/exception/GlobalExceptionHandler.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; +import com.pgms.coredomain.domain.common.BaseErrorCode; import com.pgms.coredomain.domain.common.MemberErrorCode; import com.pgms.coredomain.response.ErrorResponse; @@ -29,7 +30,7 @@ protected ResponseEntity handleGlobalException(Exception ex) { @ExceptionHandler(CustomException.class) protected ResponseEntity handleEventCustomException(CustomException ex) { log.warn(">>>>> Custom Exception : {}", ex); - MemberErrorCode errorCode = ex.getErrorCode(); + BaseErrorCode errorCode = ex.getErrorCode(); return ResponseEntity.status(errorCode.getStatus()).body(errorCode.getErrorResponse()); } diff --git a/core/core-domain/src/main/java/com/pgms/coredomain/domain/common/BaseErrorCode.java b/core/core-domain/src/main/java/com/pgms/coredomain/domain/common/BaseErrorCode.java index 442af541..4b73cebf 100644 --- a/core/core-domain/src/main/java/com/pgms/coredomain/domain/common/BaseErrorCode.java +++ b/core/core-domain/src/main/java/com/pgms/coredomain/domain/common/BaseErrorCode.java @@ -1,7 +1,13 @@ package com.pgms.coredomain.domain.common; +import org.springframework.http.HttpStatus; + import com.pgms.coredomain.response.ErrorResponse; public interface BaseErrorCode { ErrorResponse getErrorResponse(); + + String getMessage(); + + HttpStatus getStatus(); }