gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 01/02: Reduce logging from /ebicsweb.


From: gnunet
Subject: [libeufin] 01/02: Reduce logging from /ebicsweb.
Date: Fri, 18 Nov 2022 06:52:04 +0100

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

ms pushed a commit to branch master
in repository libeufin.

commit 86444ff8fa85285a0e1f2ba6bbc72cd8c8899c94
Author: MS <ms@taler.net>
AuthorDate: Fri Nov 18 06:04:54 2022 +0100

    Reduce logging from /ebicsweb.
---
 .../kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt    |  8 ++------
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt       | 13 +++++--------
 .../main/kotlin/tech/libeufin/sandbox/XMLEbicsConverter.kt  |  9 ++++++++-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git 
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 28aaa823..814874c9 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -71,7 +71,7 @@ data class PainParseResult(
 open class EbicsRequestError(
     val errorText: String,
     val errorCode: String
-) : Exception("EBICS request  error: $errorText ($errorCode)")
+) : Exception("$errorText ($errorCode)")
 
 class EbicsNoDownloadDataAvailable(camtType: Int) : EbicsRequestError(
     "[EBICS_NO_DOWNLOAD_DATA_AVAILABLE] for Camt $camtType",
@@ -131,7 +131,7 @@ suspend fun respondEbicsTransfer(
      * which Ebics host was requested belongs to the request document.
      *
      * Therefore, because any (? Please verify!) Ebics response
-     * should speak for one Ebics host, we won't respond any Ebics
+     * should speak for one Ebics host, we can't respond any Ebics
      * type when the Ebics host ID remains unknown due to invalid
      * request.  Instead, we'll respond plain text:
      */
@@ -985,10 +985,6 @@ fun receiveEbicsXmlInternal(xmlData: String): Document {
     }
     return requestDocument
 }
-suspend fun ApplicationCall.receiveEbicsXml(): Document {
-    val body: String = receiveText()
-    return receiveEbicsXmlInternal(body)
-}
 
 private fun makePartnerInfo(subscriber: EbicsSubscriberEntity): 
EbicsTypes.PartnerInfo {
     val bankAccount = getBankAccountFromSubscriber(subscriber)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 1bc6f312..b442d75a 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -969,15 +969,14 @@ val sandboxApp: Application.() -> Unit = {
                 call.ebicsweb()
             }
             /**
-             * The catch blocks below act as translators from
-             * generic error types to EBICS-formatted responses.
-             */
+             * The catch blocks try to extract a EBICS error message from the
+             * exception type being handled.  NOT (double) logging under each
+             * catch block as ultimately the registered exception handler is 
expected
+             * to log. */
             catch (e: UtilError) {
-                logger.error(e.reason)
                 throw EbicsProcessingError("Serving EBICS threw unmanaged 
UtilError: ${e.reason}")
             }
             catch (e: SandboxError) {
-                logger.error(e.reason)
                 // Should translate to EBICS error code.
                 when (e.errorCode) {
                     LibeufinErrorCode.LIBEUFIN_EC_INVALID_STATE -> throw 
EbicsProcessingError("Invalid bank state.")
@@ -989,14 +988,12 @@ val sandboxApp: Application.() -> Unit = {
                 respondEbicsTransfer(call, e.errorText, e.errorCode)
             }
             catch (e: EbicsRequestError) {
-                logger.error(e.errorText)
                 // Preventing the last catch-all block
                 // from capturing a known type.
                 throw e
             }
             catch (e: Exception) {
-                logger.error(e.message)
-                throw EbicsProcessingError("Unmanaged error: $e")
+                throw EbicsProcessingError("Could not map error to EBICS code: 
$e")
             }
             return@post
         }
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLEbicsConverter.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLEbicsConverter.kt
index 632d94ee..4f80f96c 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLEbicsConverter.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/XMLEbicsConverter.kt
@@ -20,7 +20,14 @@ class XMLEbicsConverter : ContentConverter {
         context: PipelineContext<ApplicationReceiveRequest, ApplicationCall>): 
Any? {
         val value = context.subject.value as? ByteReadChannel ?: return null
         return withContext(Dispatchers.IO) {
-            receiveEbicsXmlInternal(value.toInputStream().reader().readText())
+            try {
+                
receiveEbicsXmlInternal(value.toInputStream().reader().readText())
+            } catch (e: Exception) {
+                throw SandboxError(
+                    HttpStatusCode.BadRequest,
+                    "Document is invalid XML."
+                )
+            }
         }
     }
     override suspend fun convertForSend(

-- 
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]