gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (555c76bc -> 0583cf84)


From: gnunet
Subject: [libeufin] branch master updated (555c76bc -> 0583cf84)
Date: Fri, 18 Nov 2022 06:52:03 +0100

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

ms pushed a change to branch master
in repository libeufin.

    from 555c76bc Reduce logging.
     new 86444ff8 Reduce logging from /ebicsweb.
     new 0583cf84 reduce logging

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/sandbox/EbicsProtocolBackend.kt  |  8 ++------
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 23 +++++++++-------------
 .../tech/libeufin/sandbox/XMLEbicsConverter.kt     |  9 ++++++++-
 util/src/main/kotlin/HTTP.kt                       |  4 +++-
 4 files changed, 22 insertions(+), 22 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..7e328f67 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -476,9 +476,7 @@ val sandboxApp: Application.() -> Unit = {
         this.level = Level.DEBUG
         this.logger = tech.libeufin.sandbox.logger
         this.format { call ->
-            val t = Thread.currentThread()
-            "${call.response.status()}, ${call.request.httpMethod.value} 
${call.request.path()}" +
-                    " - thread (id/name/group): 
${t.id}/${t.name}/${t.threadGroup.name}"
+            "${call.response.status()}, ${call.request.httpMethod.value} 
${call.request.path()}"
         }
     }
     install(CORS) {
@@ -507,7 +505,7 @@ val sandboxApp: Application.() -> Unit = {
     }
     install(StatusPages) {
         exception<ArithmeticException> { cause ->
-            logger.error("Exception while handling '${call.request.uri}'", 
cause)
+            logger.error("Exception while handling '${call.request.uri}', 
${cause.message}")
             call.respondText(
                 "Invalid arithmetic attempted.",
                 ContentType.Text.Plain,
@@ -529,7 +527,7 @@ val sandboxApp: Application.() -> Unit = {
             )
         }
         exception<UtilError> { cause ->
-            logger.error("Exception while handling '${call.request.uri}'", 
cause)
+            logger.error("Exception while handling '${call.request.uri}', 
${cause.reason}")
             call.respond(
                 cause.statusCode,
                 SandboxErrorJson(
@@ -545,7 +543,7 @@ val sandboxApp: Application.() -> Unit = {
             respondEbicsTransfer(call, e.errorText, e.errorCode)
         }
         exception<Throwable> { cause ->
-            logger.error("Exception while handling '${call.request.uri}'", 
cause)
+            logger.error("Exception while handling '${call.request.uri}'", 
cause.message)
             call.respondText(
                 "Internal server error.",
                 ContentType.Text.Plain,
@@ -969,15 +967,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 +986,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(
diff --git a/util/src/main/kotlin/HTTP.kt b/util/src/main/kotlin/HTTP.kt
index 387a7b05..647a331f 100644
--- a/util/src/main/kotlin/HTTP.kt
+++ b/util/src/main/kotlin/HTTP.kt
@@ -19,7 +19,9 @@ fun unauthorized(msg: String): UtilError {
 
 fun notFound(msg: String): UtilError {
     return UtilError(
-        HttpStatusCode.NotFound, msg, LibeufinErrorCode.LIBEUFIN_EC_NONE
+        HttpStatusCode.NotFound,
+        msg,
+        LibeufinErrorCode.LIBEUFIN_EC_NONE
     )
 }
 

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