Skip to content

Commit 6b01304

Browse files
committed
feat: 최대 금액 예외 추가
1 parent 48b6161 commit 6b01304

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

apps/commerce-api/src/main/java/com/loopers/domain/point/PointBalance.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ public PointBalance charge(Long amount) {
4444
if (amount == null || amount <= 0) {
4545
throw new CoreException(ErrorType.BAD_REQUEST, "충전 금액은 0보다 커야 합니다.");
4646
}
47+
if (this.value > Long.MAX_VALUE - amount) {
48+
throw new CoreException(ErrorType.BAD_REQUEST, "충전 가능한 최대 금액을 초과했습니다.");
49+
}
4750
return new PointBalance(this.value + amount);
4851
}
4952

5053
public PointBalance use(Long amount) {
5154
if (amount == null || amount <= 0) {
5255
throw new CoreException(ErrorType.BAD_REQUEST, "사용 금액은 0보다 커야 합니다.");
5356
}
54-
if (this.value > Long.MAX_VALUE - amount) {
55-
throw new CoreException(ErrorType.BAD_REQUEST, "충전 가능한 최대 금액을 초과했습니다.");
56-
}
5757
if (this.value < amount) {
5858
throw new CoreException(ErrorType.BAD_REQUEST, "보유 포인트가 부족합니다.");
5959
}

0 commit comments

Comments
 (0)