-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 예외 핸들링 추가 * refactor: 예외 메시지 구체화 및 검증 역할 변경 * feat: 에러 코드 추가 * style: 개행 제거 * refactor: 멤버 액션 예외 ErrorCode 분리 * feat: 로깅 추가
- Loading branch information
Showing
9 changed files
with
134 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
server/src/main/java/server/haengdong/exception/ErrorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
package server.haengdong.exception; | ||
|
||
public record ErrorResponse( | ||
String code, | ||
String message | ||
) { | ||
|
||
public static ErrorResponse of(String message) { | ||
return new ErrorResponse(message); | ||
public static ErrorResponse of(HaengdongErrorCode errorCode) { | ||
return new ErrorResponse(errorCode.getCode(), errorCode.getMessage()); | ||
} | ||
|
||
public static ErrorResponse of(HaengdongErrorCode errorCode, String message){ | ||
return new ErrorResponse(errorCode.getCode(), message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
server/src/main/java/server/haengdong/exception/HaengdongErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package server.haengdong.exception; | ||
|
||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
public enum HaengdongErrorCode { | ||
BAD_REQUEST(HttpStatus.BAD_REQUEST, "잘못된 요청입니다."), | ||
DUPLICATED_MEMBER_ACTION(HttpStatus.BAD_REQUEST, "올바르지 않은 인원 요청입니다."), | ||
INVALID_MEMBER_ACTION(HttpStatus.BAD_REQUEST, "잘못된 맴버 액션입니다."), | ||
|
||
NOT_FOUND_EVENT(HttpStatus.NOT_FOUND, "존재하지 않는 행사입니다."), | ||
|
||
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버 내부에서 에러가 발생했습니다."), | ||
BAD_REQUEST("R_001", "잘못된 요청입니다."), | ||
NO_RESOURCE_REQUEST("R_002", "잘못된 엔드포인트입니다."), | ||
MESSAGE_NOT_READABLE("R_003", "읽을 수 없는 요청 형식입니다."), | ||
DUPLICATED_MEMBER_ACTION("MA_001", "중복된 인원이 존재합니다."), | ||
INVALID_MEMBER_IN_ACTION("MA_002", "현재 참여하고 있는 인원이 존재합니다."), | ||
INVALID_MEMBER_OUT_ACTION("MA_003", "현재 참여하고 있지 않는 인원이 존재합니다."), | ||
NOT_FOUND_EVENT("EV_400", "존재하지 않는 행사입니다."), | ||
INTERNAL_SERVER_ERROR("S_001", "서버 내부에서 에러가 발생했습니다."), | ||
; | ||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
HaengdongErrorCode(HttpStatus httpStatus, String message) { | ||
this.httpStatus = httpStatus; | ||
HaengdongErrorCode(String code, String message) { | ||
this.code = code; | ||
this.message = message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.