Repository: digitalfabrik/entitlementcard
Issue: Uncaught exception in backend

**Describe the bug**

```
Feb 28 09:37:08 ehrenamtskarte backend[162009]: [qtp985487390-16] WARN io.javalin.Javalin - Uncaught exception
Feb 28 09:37:08 ehrenamtskarte backend[162009]: java.io.IOException: Unable to parse GraphQL payload.
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at app.ehrenamtskarte.backend.common.webservice.GraphQLHandler.getPayload(GraphQLHandler.kt:69)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at app.ehrenamtskarte.backend.common.webservice.GraphQLHandler.handle(GraphQLHandler.kt:119)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at app.ehrenamtskarte.backend.common.webservice.WebService$start$1.handle(WebService.kt:55)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.core.security.SecurityUtil.noopAccessManager(SecurityUtil.kt:23)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.http.JavalinServlet$addHandler$protectedHandler$1.handle(JavalinServlet.kt:121)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.http.JavalinServlet$service$2$1.invoke(JavalinServlet.kt:45)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.http.JavalinServlet$service$2$1.invoke(JavalinServlet.kt:24)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.http.JavalinServlet$service$1.invoke(JavalinServlet.kt:129)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.http.JavalinServlet$service$2.invoke(JavalinServlet.kt:40)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.http.JavalinServlet.service(JavalinServlet.kt:81)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.websocket.JavalinWsServlet.service(JavalinWsServlet.kt:51)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:569)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at io.javalin.core.JavalinServer$start$wsAndHttpHandler$1.doHandle(JavalinServer.kt:49)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:507)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1292)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:173)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.Server.handle(Server.java:501)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
Feb 28 09:37:08 ehrenamtskarte backend[162009]:         at java.base/java.lang.Thread.run(Thread.java:829)
```


Changed files:
backend/src/main/kotlin/app/ehrenamtskarte/backend/common/webservice/GraphQLHandler.kt

diff --git a/backend/src/main/kotlin/app/ehrenamtskarte/backend/common/webservice/GraphQLHandler.kt b/backend/src/main/kotlin/app/ehrenamtskarte/backend/common/webservice/GraphQLHandler.kt
index 00070140..bb34f963 100644
--- a/backend/src/main/kotlin/app/ehrenamtskarte/backend/common/webservice/GraphQLHandler.kt
+++ b/backend/src/main/kotlin/app/ehrenamtskarte/backend/common/webservice/GraphQLHandler.kt
@@ -116,11 +116,11 @@ class GraphQLHandler(
      * Execute a query against schema
      */
     fun handle(context: Context, applicationData: File) {
-        val (payload, files) = getPayload(context)
-        val graphQLContext = getGraphQLContext(context, files, applicationData)
-
         // Execute the query against the schema
         try {
+            val (payload, files) = getPayload(context)
+            val graphQLContext = getGraphQLContext(context, files, applicationData)
+            
             val variables = payload.getOrDefault("variables", emptyMap<String, Any>()) as Map<String, Any>?
             val executionInput =
                 ExecutionInput.Builder()
@@ -135,6 +135,8 @@ class GraphQLHandler(
 
             // write response as json
             context.json(result)
+        } catch (e: IOException) {
+            context.res.sendError(500)
         } catch (e: UnauthorizedException) {
             context.res.sendError(401)
         } catch (e: ExecutionException) {