commit 86444ff8fa85285a0e1f2ba6bbc72cd8c8899c94
parent 555c76bc93897072f573d80c0ab1d7a36d9259c4
Author: MS <ms@taler.net>
Date: Fri, 18 Nov 2022 06:04:54 +0100
Reduce logging from /ebicsweb.
Diffstat:
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
@@ -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
@@ -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
@@ -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(