gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: more error codes


From: gnunet
Subject: [libeufin] branch master updated: more error codes
Date: Wed, 22 Sep 2021 08:37:49 +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 197996d  more error codes
197996d is described below

commit 197996d952573f0103567c4e5b33ba53b1a316cb
Author: ms <ms@taler.net>
AuthorDate: Wed Sep 22 08:37:44 2021 +0200

    more error codes
---
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt       |  4 ++--
 .../src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt    | 13 ++++++++++++-
 util/src/main/kotlin/LibeufinErrorCodes.kt                  | 11 +++++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index b7a65ed..bc82621 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -434,7 +434,7 @@ fun serverMain(dbName: String, port: Int) {
                 )
             }
             exception<SandboxError> { 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(
@@ -1026,7 +1026,7 @@ fun serverMain(dbName: String, port: Int) {
                 val ret = TalerWithdrawalStatus(
                     selection_done = wo.selectionDone,
                     transfer_done = wo.transferDone,
-                    amount = "${currencyEnv}:1",
+                    amount = "${currencyEnv}:5",
                     suggested_exchange = 
"https://exchange.${envName}.taler.net/";
                 )
                 call.respond(ret)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
index e42cc25..0a43245 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
@@ -1,6 +1,7 @@
 package tech.libeufin.sandbox
 
 import io.ktor.http.*
+import org.apache.http.HttpStatus
 import org.jetbrains.exposed.sql.and
 import org.jetbrains.exposed.sql.transactions.transaction
 import org.slf4j.Logger
@@ -143,8 +144,18 @@ fun wireTransfer(
         } catch (e: Exception) {
             throw SandboxError(HttpStatusCode.BadRequest, "Amount given not 
valid: $amount")
         }
+        // Extra check on the currency's consistency
+        if (credit.currency != debit.currency) throw SandboxError(
+            HttpStatusCode.InternalServerError,
+            "Credit and debit account have different currency 
(${credit.currency} vs ${debit.currency})!",
+            LibeufinErrorCode.LIBEUFIN_EC_CURRENCY_INCONSISTENT
+        )
         if (amountObj.currency != credit.currency || amountObj.currency != 
debit.currency) {
-            throw SandboxError(HttpStatusCode.BadRequest, "currency 
(${amountObj.currency}) can't be accepted")
+            throw SandboxError(
+                HttpStatusCode.BadRequest,
+                "Currency (${amountObj.currency}) is not supported",
+                LibeufinErrorCode.LIBEUFIN_EC_BAD_CURRENCY
+            )
         }
         val randId = getRandomString(16)
         BankAccountTransactionEntity.new {
diff --git a/util/src/main/kotlin/LibeufinErrorCodes.kt 
b/util/src/main/kotlin/LibeufinErrorCodes.kt
index 3bc5fbc..6020422 100644
--- a/util/src/main/kotlin/LibeufinErrorCodes.kt
+++ b/util/src/main/kotlin/LibeufinErrorCodes.kt
@@ -61,4 +61,15 @@ enum class LibeufinErrorCode(val code: Int) {
      * (A value of 0 indicates that the error is generated client-side).
      */
     LIBEUFIN_EC_GENERIC_PARAMETER_MALFORMED(5),
+
+    /**
+     * Two different resources are NOT having the same currency.
+     */
+    LIBEUFIN_EC_CURRENCY_INCONSISTENT(6),
+
+    /**
+     * A request is using a unsupported currency.  Usually returned
+     * along 400 Bad Request
+     */
+    LIBEUFIN_EC_BAD_CURRENCY(7)
 }
\ No newline at end of file

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