gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Capture status code from error object.


From: gnunet
Subject: [libeufin] branch master updated: Capture status code from error object.
Date: Mon, 09 Mar 2020 15:44:34 +0100

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

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 70b95e9  Capture status code from error object.
70b95e9 is described below

commit 70b95e9aee7d84d835cc25dd512a24d16604f63b
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Mar 9 15:44:13 2020 +0100

    Capture status code from error object.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 0e09d69..283e4b5 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -83,7 +83,8 @@ fun testData() {
     }
 }
 
-data class NexusError(val statusCode: HttpStatusCode, val reason: String) : 
Exception(reason)
+data class NexusError(val statusCode: HttpStatusCode, val reason: String) : 
Exception()
+
 
 val logger: Logger = LoggerFactory.getLogger("tech.libeufin.nexus")
 
@@ -300,9 +301,13 @@ fun main() {
             }
         }
         install(StatusPages) {
-            exception<Throwable> { cause ->
+            exception<NexusError> { cause ->
                 logger.error("Exception while handling '${call.request.uri}'", 
cause)
-                call.respondText("Internal server error.\n", 
ContentType.Text.Plain, HttpStatusCode.InternalServerError)
+                call.respondText(
+                    cause.reason,
+                    ContentType.Text.Plain,
+                    cause.statusCode
+                )
             }
 
             exception<javax.xml.bind.UnmarshalException> { cause ->

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]