[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Wrap ebicsweb() in a try-catch block.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Wrap ebicsweb() in a try-catch block. |
Date: |
Tue, 07 Sep 2021 10:38:55 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 42f6a84 Wrap ebicsweb() in a try-catch block.
42f6a84 is described below
commit 42f6a845dd0769deae0fb9bb43f505e369ef9fcd
Author: MS <ms@taler.net>
AuthorDate: Tue Sep 7 08:38:26 2021 +0000
Wrap ebicsweb() in a try-catch block.
---
.../tech/libeufin/sandbox/EbicsProtocolBackend.kt | 5 ++---
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 23 +++++++++++++++++++++-
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index 6dccba3..ec4d00f 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -109,10 +109,9 @@ private class EbicsUnsupportedOrderType :
EbicsRequestError(
/**
* Used here also for "Internal server error". For example, when the
- * sandbox itself generates a invalid XML response. Strictly, this error
- * should only be used for _business_ related problems.
+ * sandbox itself generates a invalid XML response.
*/
-private class EbicsProcessingError(detail: String) : EbicsRequestError(
+class EbicsProcessingError(detail: String) : EbicsRequestError(
"[EBICS_PROCESSING_ERROR] $detail",
"091116"
)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 2db5ad7..8c54cef 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -908,7 +908,28 @@ fun serverMain(dbName: String, port: Int) {
* Serves all the Ebics requests.
*/
post("/ebicsweb") {
- call.ebicsweb()
+ try {
+ call.ebicsweb()
+ }
+ /**
+ * Those errors were all detected by the bank's logic.
+ */
+ catch (e: SandboxError) {
+ // Should translate to EBICS error code.
+ when(e.errorCode) {
+ LibeufinErrorCode.LIBEUFIN_EC_INVALID_STATE -> throw
EbicsProcessingError("Invalid bank state.")
+ LibeufinErrorCode.LIBEUFIN_EC_INCONSISTENT_STATE ->
throw EbicsProcessingError("Inconsistent bank state.")
+ else -> throw EbicsProcessingError("Unknown LibEuFin
error code: ${e.errorCode}.")
+ }
+
+ }
+ /**
+ * An error occurred, but it wasn't explicitly thrown by the
bank.
+ */
+ catch (e: Exception) {
+ throw EbicsProcessingError("Unmanaged error: $e")
+ }
+
}
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Wrap ebicsweb() in a try-catch block.,
gnunet <=