diff --git a/src/main/java/com/smunity/petition/global/common/code/BaseErrorCode.java b/src/main/java/com/smunity/petition/global/common/code/BaseErrorCode.java index 9a987df..c8a0ea8 100644 --- a/src/main/java/com/smunity/petition/global/common/code/BaseErrorCode.java +++ b/src/main/java/com/smunity/petition/global/common/code/BaseErrorCode.java @@ -1,7 +1,18 @@ package com.smunity.petition.global.common.code; +import com.smunity.petition.global.common.ApiResponse; +import org.springframework.http.HttpStatus; + public interface BaseErrorCode { ErrorReasonDTO getReason(); ErrorReasonDTO getReasonHttpStatus(); + + HttpStatus getHttpStatus(); + + String getCode(); + + String getMessage(); + + ApiResponse getErrorResponse(); } diff --git a/src/main/java/com/smunity/petition/global/common/code/status/ErrorCode.java b/src/main/java/com/smunity/petition/global/common/code/status/ErrorCode.java index 1d5386d..b413b83 100644 --- a/src/main/java/com/smunity/petition/global/common/code/status/ErrorCode.java +++ b/src/main/java/com/smunity/petition/global/common/code/status/ErrorCode.java @@ -1,5 +1,6 @@ package com.smunity.petition.global.common.code.status; +import com.smunity.petition.global.common.ApiResponse; import com.smunity.petition.global.common.code.BaseErrorCode; import com.smunity.petition.global.common.code.ErrorReasonDTO; import lombok.AllArgsConstructor; @@ -19,6 +20,12 @@ public enum ErrorCode implements BaseErrorCode { AUTH_UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "AUTH401", "아이디 및 비밀번호가 일치하지 않습니다."), AUTH_INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "AUTH500", "인증 서버 에러, 관리자에게 문의 바랍니다."), + // 멤버 관련 에러 + USER_NOT_FOUND(HttpStatus.BAD_REQUEST, "USER401", "사용자가 없습니다."), + NICKNAME_NOT_EXIST(HttpStatus.BAD_REQUEST, "USER402", "닉네임은 필수 입니다."), + PASSWORD_NOT_EQUAL(HttpStatus.BAD_REQUEST, "USER403", "비밀번호가 일치하지 않습니다."), + USER_ALREADY_EXIST(HttpStatus.BAD_REQUEST, "USER404", "사용자가 이미 존재합니다."), + //question 관련 에러 QUESTION_NOT_FOUND(HttpStatus.NOT_FOUND,"QUESTION404", "해당 질문이 존재하지 않습니다."), ANSWER_NOT_FOUND(HttpStatus.NOT_FOUND, "ANSWER404", "해당 답변이 존재하지 않습니다."), @@ -45,4 +52,9 @@ public ErrorReasonDTO getReasonHttpStatus() { .httpStatus(httpStatus) .build(); } + + @Override + public ApiResponse getErrorResponse() { + return ApiResponse.onFailure(code, message, null); + } }