summaryrefslogtreecommitdiff
path: root/nexus/src/main/kotlin/tech/libeufin/nexus/server
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-08-07 22:35:12 +0200
committerFlorian Dold <florian@dold.me>2021-08-07 22:35:12 +0200
commitc327e13187d053014195ae141f3e7001cc18de7e (patch)
treeeb9dcf25aeeea79afaea1197525ed08331ac1d7c /nexus/src/main/kotlin/tech/libeufin/nexus/server
parenta48071fa8bb1de5bfb6b07102f170cc5053212da (diff)
downloadlibeufin-c327e13187d053014195ae141f3e7001cc18de7e.tar.gz
libeufin-c327e13187d053014195ae141f3e7001cc18de7e.tar.bz2
libeufin-c327e13187d053014195ae141f3e7001cc18de7e.zip
towards taler-style error codes
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin/nexus/server')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt6
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt27
2 files changed, 18 insertions, 15 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
index 2c46699f..f6e8c75b 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/JSON.kt
@@ -113,6 +113,12 @@ data class NexusMessage(
val message: String
)
+data class ErrorResponse(
+ val code: Int,
+ val hint: String,
+ val detail: String,
+)
+
data class BankConnectionInfo(
val name: String,
val type: String
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 9737090c..83e77f36 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -189,11 +189,10 @@ fun serverMain(host: String, port: Int) {
logger.error("Caught exception while handling '${call.request.uri} (${cause.reason})")
call.respond(
status = cause.statusCode,
- message = NexusErrorJson(
- error = NexusErrorDetailJson(
- description = cause.reason,
- type = "nexus-error"
- )
+ message = ErrorResponse(
+ code = TalerErrorCode.TALER_EC_LIBEUFIN_NEXUS_GENERIC_ERROR.code,
+ hint = "nexus error, see detail",
+ detail = cause.reason,
)
)
}
@@ -201,11 +200,10 @@ fun serverMain(host: String, port: Int) {
logger.error("Caught exception while handling '${call.request.uri}' (${cause.reason})")
call.respond(
cause.httpStatusCode,
- NexusErrorJson(
- error = NexusErrorDetailJson(
- type = "ebics-protocol-error",
- description = cause.reason
- )
+ message = ErrorResponse(
+ code = TalerErrorCode.TALER_EC_LIBEUFIN_NEXUS_GENERIC_ERROR.code,
+ hint = "EBICS protocol error",
+ detail = cause.reason,
)
)
}
@@ -214,11 +212,10 @@ fun serverMain(host: String, port: Int) {
cause.printStackTrace()
call.respond(
HttpStatusCode.InternalServerError,
- NexusErrorJson(
- error = NexusErrorDetailJson(
- type = "nexus-error",
- description = "Internal server error"
- )
+ ErrorResponse(
+ code = TalerErrorCode.TALER_EC_LIBEUFIN_NEXUS_UNCAUGHT_EXCEPTION.code,
+ hint = "unexpected exception",
+ detail = "exception message: ${cause.message}",
)
)
}