Skip to content

Commit

Permalink
refactor: 예외 메시지 전달 방법 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachneee committed Jul 25, 2024
1 parent 4d3c9e7 commit d334b0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ public BillAction(Action action, String title, Long price) {
private void validateTitle(String title) {
int titleLength = title.trim().length();
if (titleLength < MIN_TITLE_LENGTH || titleLength > MAX_TITLE_LENGTH) {
throw new HaengdongException(HaengdongErrorCode.INVALID_BILL_ACTION_SIZE);
throw new HaengdongException(HaengdongErrorCode.BAD_REQUEST,
String.format("앞뒤 공백을 제거한 지출 내역 제목은 %d ~ %d자여야 합니다.", MIN_TITLE_LENGTH, MAX_TITLE_LENGTH));
}
}

private void validatePrice(Long price) {
if (price < MIN_PRICE || price > MAX_PRICE) {
throw new HaengdongException(HaengdongErrorCode.INVALID_PRICE_SIZE);
throw new HaengdongException(HaengdongErrorCode.BAD_REQUEST,
String.format("지출 금액은 %,d 이하의 자연수여야 합니다.", MAX_PRICE));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public enum HaengdongErrorCode {
BAD_REQUEST(HttpStatus.BAD_REQUEST, "잘못된 요청입니다."),
DUPLICATED_MEMBER_ACTION(HttpStatus.BAD_REQUEST, "올바르지 않은 인원 요청입니다."),
INVALID_MEMBER_ACTION(HttpStatus.BAD_REQUEST, "잘못된 맴버 액션입니다."),
INVALID_BILL_ACTION_SIZE(HttpStatus.BAD_REQUEST, "앞뒤 공백을 제거한 지출 내역 제목은 2 ~ 30자여야 합니다."),
INVALID_PRICE_SIZE(HttpStatus.BAD_REQUEST, "지출 금액은 10,000,000 이하의 자연수여야 합니다."),

NOT_FOUND_EVENT(HttpStatus.NOT_FOUND, "존재하지 않는 행사입니다."),

Expand Down

0 comments on commit d334b0b

Please sign in to comment.