Skip to content

Commit

Permalink
remove unnecessary exception translation
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Lee <[email protected]>
  • Loading branch information
lukelee-sl committed Dec 24, 2024
1 parent 1861d60 commit 2a4f9c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,10 @@ private void consolidateInto(
}

private AccountAmount mergeAdjusts(@NonNull final AccountAmount from, @NonNull final AccountAmount to) {
try {
return from.copyBuilder()
.amount(Math.addExact(from.amount(), to.amount()))
.isApproval(from.isApproval() || to.isApproval())
.build();
} catch (ArithmeticException e) {
throw new IllegalArgumentException("Amount overflow when merging account amounts");
}
return from.copyBuilder()
.amount(Math.addExact(from.amount(), to.amount()))
.isApproval(from.isApproval() || to.isApproval())
.build();
}

private List<NftTransfer> mergeNftTransfers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ void decodeCryptoTransferOverflow() {
.build(),
EMPTY_TUPLE_ARRAY);
Assertions.assertThatThrownBy(() -> subject.decodeCryptoTransferV2(encodedInput.array(), converter))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Amount overflow when merging account amounts");
.isInstanceOf(ArithmeticException.class);
}

@Test
Expand All @@ -153,8 +152,7 @@ void decodeCryptoTokenTransferOverflow() {
.build())
.build());
Assertions.assertThatThrownBy(() -> subject.decodeCryptoTransferV2(encodedInput.array(), converter))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Amount overflow when merging account amounts");
.isInstanceOf(ArithmeticException.class);
}

private static List<AccountAmount> unwrapTokenAmounts(final TransactionBody body) {
Expand Down

0 comments on commit 2a4f9c5

Please sign in to comment.