Skip to content

Commit

Permalink
✨ feat: 에러코드 부분 작성 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiiiiiw committed Feb 29, 2024
1 parent 6bb3c4d commit 6299ec1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Void> getErrorResponse();
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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", "해당 답변이 존재하지 않습니다."),
Expand All @@ -45,4 +52,9 @@ public ErrorReasonDTO getReasonHttpStatus() {
.httpStatus(httpStatus)
.build();
}

@Override
public ApiResponse<Void> getErrorResponse() {
return ApiResponse.onFailure(code, message, null);
}
}

0 comments on commit 6299ec1

Please sign in to comment.