commit 5a5da42eb8bed68e1aa1ca00a9484bb6717edcfd
parent 3d1dfce83bf74917886a5f3cc55aa7f97b74aac4
Author: Antoine A <>
Date: Tue, 13 Feb 2024 21:20:48 +0100
Improve unknown creditor account logs
Diffstat:
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/CoreBankApi.kt
@@ -468,10 +468,7 @@ private fun Routing.coreBankTransactionsApi(db: Database, ctx: BankConfig) {
"Wire transfer attempted with credit and debit party being the same bank account",
TalerErrorCode.BANK_SAME_ACCOUNT
)
- BankTransactionResult.UnknownCreditor -> throw conflict(
- "Creditor account was not found",
- TalerErrorCode.BANK_UNKNOWN_CREDITOR
- )
+ BankTransactionResult.UnknownCreditor -> throw unknownCreditorAccount(req.payto_uri.canonical)
BankTransactionResult.AdminCreditor -> throw conflict(
"Cannot transfer money to admin account",
TalerErrorCode.BANK_ADMIN_CREDITOR
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Error.kt b/bank/src/main/kotlin/tech/libeufin/bank/Error.kt
@@ -153,6 +153,13 @@ fun unknownAccount(id: String): LibeufinException {
)
}
+fun unknownCreditorAccount(id: String): LibeufinException {
+ return conflict(
+ "Creditor account '$id' not found",
+ TalerErrorCode.BANK_UNKNOWN_CREDITOR
+ )
+}
+
fun unsupportedTanChannel(channel: TanChannel): LibeufinException {
return conflict(
"Unsupported tan channel $channel",
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/WireGatewayApi.kt b/bank/src/main/kotlin/tech/libeufin/bank/WireGatewayApi.kt
@@ -60,10 +60,7 @@ fun Routing.wireGatewayApi(db: Database, ctx: BankConfig) {
"$username is not an exchange account.",
TalerErrorCode.BANK_ACCOUNT_IS_NOT_EXCHANGE
)
- is TransferResult.UnknownCreditor -> throw conflict(
- "Creditor account was not found",
- TalerErrorCode.BANK_UNKNOWN_CREDITOR
- )
+ is TransferResult.UnknownCreditor -> throw unknownCreditorAccount(req.credit_account.canonical)
is TransferResult.BothPartyAreExchange -> throw conflict(
"Wire transfer attempted with credit and debit party being both exchange account",
TalerErrorCode.BANK_ACCOUNT_IS_EXCHANGE