From 437f04dbc1e27ffd14bf26f649181f1c378ec304 Mon Sep 17 00:00:00 2001 From: Vusumuzi Khoza Date: Wed, 20 May 2026 17:32:35 +0200 Subject: [PATCH] updating error handling --- .../qantra/tm/domain/models/Transaction.java | 2 + .../HotRechargeIntegrationProcessor.java | 6 +- .../EcocashRemotePaymentProcessor.java | 6 +- .../resources/liquibase-diff-changeLog.xml | 317 ------------------ 4 files changed, 10 insertions(+), 321 deletions(-) delete mode 100644 src/main/resources/liquibase-diff-changeLog.xml diff --git a/src/main/java/zw/qantra/tm/domain/models/Transaction.java b/src/main/java/zw/qantra/tm/domain/models/Transaction.java index 58b866e..ee5cb3d 100644 --- a/src/main/java/zw/qantra/tm/domain/models/Transaction.java +++ b/src/main/java/zw/qantra/tm/domain/models/Transaction.java @@ -94,6 +94,8 @@ public class Transaction extends BaseEntity { @Column(columnDefinition = "TEXT") private String errorMessage; + @Column(columnDefinition = "TEXT") + private String systemErrorMessage; private String responseCode; @Enumerated(EnumType.STRING) private Status status; diff --git a/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java b/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java index bfbadcc..2240baa 100644 --- a/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java +++ b/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java @@ -107,14 +107,16 @@ public class HotRechargeIntegrationProcessor implements TransactionProcessorInte } else { transaction.setStatus(Status.FAILED); transaction.setResponseCode((String) rechargeResponse.getOrDefault("responseCode", "99")); - transaction.setErrorMessage((String) rechargeResponse.getOrDefault("message", "Recharge failed")); + transaction.setSystemErrorMessage((String) rechargeResponse.getOrDefault("message", "Recharge failed")); + transaction.setErrorMessage("Funding billing account failed. Please try again."); } } catch (Exception e) { logger.error("Error processing HotRecharge integration: " + e.getMessage(), e); transaction.setStatus(Status.FAILED); transaction.setResponseCode("99"); - transaction.setErrorMessage("Processing error: " + e.getMessage()); + transaction.setSystemErrorMessage("Processing error: " + e.getMessage()); + transaction.setErrorMessage("Funding billing account failed. Please try again."); } return transaction; diff --git a/src/main/java/zw/qantra/tm/domain/services/processors/payments/EcocashRemotePaymentProcessor.java b/src/main/java/zw/qantra/tm/domain/services/processors/payments/EcocashRemotePaymentProcessor.java index 92f0844..676bf33 100644 --- a/src/main/java/zw/qantra/tm/domain/services/processors/payments/EcocashRemotePaymentProcessor.java +++ b/src/main/java/zw/qantra/tm/domain/services/processors/payments/EcocashRemotePaymentProcessor.java @@ -126,7 +126,8 @@ public class EcocashRemotePaymentProcessor implements TransactionProcessorInterf logger.error("Network error during payment processing: {}", e.getMessage(), e); transaction.setStatus(Status.FAILED); transaction.setResponseCode("99"); - transaction.setErrorMessage("Network error: " + e.getMessage()); + transaction.setSystemErrorMessage("Network error: " + e.getMessage()); + transaction.setErrorMessage("Payment failed. Please try again."); } return transactionService.save(transaction); @@ -187,7 +188,8 @@ public class EcocashRemotePaymentProcessor implements TransactionProcessorInterf logger.error("Network error during payment processing: {}", e.getMessage(), e); transaction.setStatus(Status.FAILED); transaction.setResponseCode("99"); - transaction.setErrorMessage("Network error: " + e.getMessage()); + transaction.setSystemErrorMessage("Network error: " + e.getMessage()); + transaction.setErrorMessage("Payment failed. Please try again."); } return transaction; diff --git a/src/main/resources/liquibase-diff-changeLog.xml b/src/main/resources/liquibase-diff-changeLog.xml deleted file mode 100644 index e7fa546..0000000 --- a/src/main/resources/liquibase-diff-changeLog.xml +++ /dev/null @@ -1,317 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -