Skip to content

Commit

Permalink
fix: CustomException의 필드를 BaseErrorCode로 변경 (#155)
Browse files Browse the repository at this point in the history
* fix: CustomException의 필드를 BaseErrorCode로 변경

* fix: BaseErrorCode 수정
  • Loading branch information
eunbc committed Jan 8, 2024
1 parent b15c196 commit 7eac749
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,7 +30,7 @@ protected ResponseEntity<ErrorResponse> handleGlobalException(Exception ex) {
@ExceptionHandler(CustomException.class)
protected ResponseEntity<ErrorResponse> handleEventCustomException(CustomException ex) {
log.warn(">>>>> Custom Exception : {}", ex);
MemberErrorCode errorCode = ex.getErrorCode();
BaseErrorCode errorCode = ex.getErrorCode();
return ResponseEntity.status(errorCode.getStatus()).body(errorCode.getErrorResponse());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 7eac749

Please sign in to comment.