[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: respond 400 on invalid JSON (was 500)
From: |
gnunet |
Subject: |
[libeufin] branch master updated: respond 400 on invalid JSON (was 500) |
Date: |
Wed, 27 Jan 2021 15:20:03 +0100 |
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 5e17e49 respond 400 on invalid JSON (was 500)
5e17e49 is described below
commit 5e17e49c054d783775e6b7c24e75f9bfc84fabbe
Author: MS <ms@taler.net>
AuthorDate: Wed Jan 27 15:19:52 2021 +0100
respond 400 on invalid JSON (was 500)
---
nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index ef10f00..d8da5fb 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -22,6 +22,7 @@ package tech.libeufin.nexus.server
import com.fasterxml.jackson.core.util.DefaultIndenter
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.core.JsonParseException
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.exc.MismatchedInputException
import com.fasterxml.jackson.module.kotlin.KotlinModule
@@ -137,7 +138,10 @@ suspend inline fun <reified T : Any>
ApplicationCall.receiveJson(): T {
} catch (e: MissingKotlinParameterException) {
throw NexusError(HttpStatusCode.BadRequest, "Missing value for
${e.pathReference}")
} catch (e: MismatchedInputException) {
- throw NexusError(HttpStatusCode.BadRequest, "Invalid value for
${e.pathReference}")
+ // Note: POSTing "[]" gets here but e.pathReference is blank.
+ throw NexusError(HttpStatusCode.BadRequest, "Invalid value for
'${e.pathReference}'")
+ } catch (e: JsonParseException) {
+ throw NexusError(HttpStatusCode.BadRequest, "Invalid JSON")
}
}
--
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: respond 400 on invalid JSON (was 500),
gnunet <=