gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (a1820a97 -> 7e326c6e)


From: gnunet
Subject: [libeufin] branch master updated (a1820a97 -> 7e326c6e)
Date: Wed, 15 Feb 2023 15:57:58 +0100

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

ms pushed a change to branch master
in repository libeufin.

    from a1820a97 addressing #6988
     new 97ab4b90 logging.
     new 7e326c6e Error management.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../tech/libeufin/nexus/ebics/EbicsClient.kt       | 68 +++++++++++++---------
 1 file changed, 42 insertions(+), 26 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 33f2f720..f24ed637 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
@@ -119,9 +119,9 @@ suspend fun doEbicsDownloadTransaction(
             // The bank gave a valid XML response but EBICS had problems.
             throw EbicsProtocolError(
                 HttpStatusCode.UnprocessableEntity,
-                "Unexpected return code ${initResponse.technicalReturnCode}," +
-                        " for order type $orderType and transaction ID: 
$transactionID," +
-                        " at init phase.",
+                "EBICS-technical error at init phase: " +
+                        "${initResponse.technicalReturnCode} 
${initResponse.reportText}," +
+                        " for order type $orderType and transaction ID: 
$transactionID.",
                 initResponse.technicalReturnCode
             )
         }
@@ -142,8 +142,8 @@ suspend fun doEbicsDownloadTransaction(
         }
         else -> {
             logger.error(
-                "Bank return code at init phase was: 
${initResponse.bankReturnCode}, for" +
-                        " order type $orderType and transaction ID 
$transactionID."
+                "Bank-technical error at init phase: 
${initResponse.bankReturnCode}" +
+                        ", for order type $orderType and transaction ID 
$transactionID."
             )
             return EbicsDownloadBankErrorResult(initResponse.bankReturnCode)
         }
@@ -153,26 +153,25 @@ suspend fun doEbicsDownloadTransaction(
     val encryptionInfo = initResponse.dataEncryptionInfo
         ?: throw NexusError(
             HttpStatusCode.BadGateway,
-            "initial response did not contain encryption info.  " +
+            "Initial response did not contain encryption info.  " +
                     "Order type $orderType, transaction ID $transactionID"
         )
 
     val initOrderDataEncChunk = initResponse.orderDataEncChunk
         ?: throw NexusError(
             HttpStatusCode.BadGateway,
-            "initial response for download transaction does not " +
-                    "contain data transfer.  Order type $orderType, 
transaction ID $transactionID."
+            "Initial response for download transaction does not " +
+                    "contain data transfer.  Order type $orderType, " +
+                    "transaction ID $transactionID."
         )
-
     payloadChunks.add(initOrderDataEncChunk)
 
     val numSegments = initResponse.numSegments
         ?: throw NexusError(
             HttpStatusCode.FailedDependency,
-            "missing segment number in EBICS download init response." +
+            "Missing segment number in EBICS download init response." +
                     "  Order type $orderType, transaction ID $transactionID"
         )
-
     // Transfer phase
     for (x in 2 .. numSegments) {
         val transferReqStr =
@@ -187,8 +186,8 @@ suspend fun doEbicsDownloadTransaction(
             else -> {
                 throw NexusError(
                     HttpStatusCode.FailedDependency,
-                    "unexpected EBICS technical return code at transfer phase: 
" +
-                            "${transferResponse.technicalReturnCode}." +
+                    "EBICS-technical error at transfer phase: " +
+                            "${transferResponse.technicalReturnCode} 
${transferResponse.reportText}." +
                             "  Order type $orderType, transaction ID 
$transactionID"
                 )
             }
@@ -198,8 +197,8 @@ suspend fun doEbicsDownloadTransaction(
                 // Success, nothing to do!
             }
             else -> {
-                logger.error("Bank return code " +
-                        "at transfer phase was: 
${transferResponse.bankReturnCode}." +
+                logger.error("Bank-technical error at transfer phase: " +
+                        "${transferResponse.bankReturnCode}." +
                         "  Order type $orderType, transaction ID 
$transactionID")
                 return 
EbicsDownloadBankErrorResult(transferResponse.bankReturnCode)
             }
@@ -261,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"
+        )
+    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.")
+    }
+    logger.debug("Bank acknowledges EBICS upload initialization. " +
+            " Transaction ID: $transactionID.")
 
     /* now send actual payload */
     val ebicsPayload = createEbicsRequestForUploadTransferPhase(
@@ -285,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]