gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Error responses.


From: gnunet
Subject: [libeufin] branch master updated: Error responses.
Date: Tue, 26 Sep 2023 23:09:56 +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 59b5282a Error responses.
59b5282a is described below

commit 59b5282a9f2aee0f886656f2451234da9962be89
Author: MS <ms@taler.net>
AuthorDate: Tue Sep 26 23:07:59 2023 +0200

    Error responses.
    
    Add the 'detail' field to include error messages from
    the root cause.
---
 bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt | 3 ++-
 bank/src/main/kotlin/tech/libeufin/bank/Main.kt         | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
index 0ca325f7..d0807f95 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/BankMessages.kt
@@ -70,7 +70,8 @@ data class TokenSuccessResponse(
 @Serializable
 data class TalerError(
     val code: Int,
-    val hint: String? = null
+    val hint: String? = null,
+    val detail: String? = null
 )
 
 /* Contains contact data to send TAN challges to the
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
index eb88d15d..c556b0f2 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
@@ -261,13 +261,13 @@ fun Application.corebankWebApp(db: Database, ctx: 
BankApplicationContext) {
              * to get the most detailed message, we must consider BOTH sides:
              * the 'cause' AND its root cause!
              */
+            logger.error(cause.message)
             var rootCause: Throwable? = cause.cause
             while (rootCause?.cause != null)
                 rootCause = rootCause.cause
             /* Here getting _some_ error message, by giving precedence
              * to the root cause, as otherwise JSON details would be lost. */
-            val errorMessage: String? = rootCause?.message ?: cause.message
-            logger.error(errorMessage)
+            logger.error(rootCause?.message)
             // Telling apart invalid JSON vs missing parameter vs invalid 
parameter.
             val talerErrorCode = when (cause) {
                 is MissingRequestParameterException ->
@@ -282,7 +282,8 @@ fun Application.corebankWebApp(db: Database, ctx: 
BankApplicationContext) {
                 status = HttpStatusCode.BadRequest,
                 message = TalerError(
                     code = talerErrorCode.code,
-                    hint = errorMessage
+                    hint = cause.message,
+                    detail = rootCause?.message
                 )
             )
         }

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