Skip to content

Commit 25f2976

Browse files
authored
fix: Improve exception handling when payer account is not meeting the specifications (#18995)
Signed-off-by: Valentin Tronkov <[email protected]>
1 parent 78f86fb commit 25f2976

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/dispatch/DispatchValidator.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ private FeeCharging.Validation getFinalPayerValidation(
142142
}
143143
return switch (duplicateStatus) {
144144
case DUPLICATE -> newPayerDuplicateError(creatorId, payer);
145-
case NO_DUPLICATE -> dispatch.preHandleResult().status() == SO_FAR_SO_GOOD
146-
? validation
147-
: newPayerUniqueError(
148-
creatorId, payer, dispatch.preHandleResult().responseCode());
145+
case NO_DUPLICATE ->
146+
dispatch.preHandleResult().status() == SO_FAR_SO_GOOD
147+
? validation
148+
: newPayerUniqueError(
149+
creatorId, payer, dispatch.preHandleResult().responseCode());
149150
};
150151
}
151152

@@ -208,9 +209,17 @@ private Account getPayerAccount(
208209
final var account = accountStore.getAccountById(accountID);
209210
return switch (category) {
210211
case USER, NODE, BATCH_INNER -> {
211-
if (account == null || account.deleted() || account.smartContract()) {
212-
throw new IllegalStateException("Category " + category
213-
+ " payer account should have resulted in failure upstream " + account);
212+
if (account == null) {
213+
throw new IllegalStateException(
214+
String.format("Category %s payer account with id %s does not exists", category, accountID));
215+
}
216+
if (account.deleted()) {
217+
throw new IllegalStateException(
218+
String.format("Category %s payer account with id %s is deleted", category, accountID));
219+
}
220+
if (account.smartContract()) {
221+
throw new IllegalStateException(String.format(
222+
"Category %s payer account with id %s is a smart contract", category, accountID));
214223
}
215224
yield account;
216225
}

0 commit comments

Comments
 (0)