gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 02/02: Error management.


From: gnunet
Subject: [libeufin] 02/02: Error management.
Date: Wed, 15 Feb 2023 15:58:00 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

commit 7e326c6e14c9c130b072f04f9ba2693fc730c52e
Author: MS <ms@taler.net>
AuthorDate: Wed Feb 15 15:57:01 2023 +0100

    Error management.
    
    Checking bank-technical error code even
    along the upload helper.
---
 .../tech/libeufin/nexus/ebics/EbicsClient.kt       | 39 ++++++++++++++++------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
index 588ff61a..f24ed637 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
@@ -260,16 +260,25 @@ suspend fun doEbicsUploadTransaction(
     if (initResponse.technicalReturnCode != EbicsReturnCode.EBICS_OK) {
         throw NexusError(
             HttpStatusCode.InternalServerError,
-            reason = "unexpected return code"
+            reason = "EBICS-technical error at init phase:" +
+                    " ${initResponse.technicalReturnCode} 
${initResponse.reportText}"
         )
     }
     // The bank did NOT indicate any error, but the response
     // lacks required information, blame the bank.
     val transactionID = initResponse.transactionID ?: throw NexusError(
             HttpStatusCode.BadGateway,
-            "init response must have transaction ID"
+            "Init response must have transaction ID"
         )
-    logger.debug("Bank acknowledges EBICS upload initialization.  Transaction 
ID: $transactionID.")
+    if (initResponse.bankReturnCode != EbicsReturnCode.EBICS_OK) {
+        throw NexusError(
+            HttpStatusCode.InternalServerError,
+            reason = "Bank-technical error at init phase:" +
+                    " ${initResponse.technicalReturnCode}"
+        )
+    }
+    logger.debug("Bank acknowledges EBICS upload initialization. " +
+            " Transaction ID: $transactionID.")
 
     /* now send actual payload */
     val ebicsPayload = createEbicsRequestForUploadTransferPhase(
@@ -284,21 +293,29 @@ suspend fun doEbicsUploadTransaction(
     )
     val txResp = parseAndValidateEbicsResponse(subscriberDetails, txRespStr)
     when (txResp.technicalReturnCode) {
-        EbicsReturnCode.EBICS_OK -> {
-        }
+        EbicsReturnCode.EBICS_OK -> {/* do nothing */}
         else -> {
+            // EBICS failed, blame Nexus.
             throw EbicsProtocolError(
-                /**
-                 * The communication was valid, but the content may have
-                 * caused a problem in the bank.  Nexus MAY but it's not 
required
-                 * to check all possible business conditions before requesting
-                 * to the bank. */
-                httpStatusCode = HttpStatusCode.UnprocessableEntity,
+                httpStatusCode = HttpStatusCode.InternalServerError,
                 reason = txResp.reportText,
                 ebicsTechnicalCode = txResp.technicalReturnCode
             )
         }
     }
+    when (txResp.bankReturnCode) {
+        EbicsReturnCode.EBICS_OK -> {/* do nothing */}
+        else -> {
+            /**
+             * Although EBICS went fine, the bank complained about
+             * the communication content.
+             */
+            throw EbicsProtocolError(
+                httpStatusCode = HttpStatusCode.UnprocessableEntity,
+                reason = "bank-technical error: ${txResp.reportText}"
+            )
+        }
+    }
     logger.debug("Bank acknowledges EBICS upload transfer.  Transaction ID: 
$transactionID")
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]