|
12 | 12 | import jakarta.json.JsonObject;
|
13 | 13 | import jakarta.json.JsonObjectBuilder;
|
14 | 14 | import jakarta.json.JsonReader;
|
| 15 | +import jakarta.json.stream.JsonParsingException; |
15 | 16 |
|
16 | 17 | import org.jboss.logging.Logger;
|
17 | 18 |
|
18 | 19 | import graphql.ErrorType;
|
19 | 20 | import graphql.ExecutionResult;
|
| 21 | +import graphql.ExecutionResultImpl; |
20 | 22 | import graphql.GraphQLError;
|
| 23 | +import graphql.GraphqlErrorBuilder; |
21 | 24 | import graphql.execution.AbortExecutionException;
|
22 | 25 | import io.quarkus.security.identity.CurrentIdentityAssociation;
|
23 | 26 | import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
|
@@ -122,6 +125,8 @@ private void handlePost(HttpServerResponse response, RoutingContext ctx, String
|
122 | 125 | }
|
123 | 126 | } catch (IOException ex) {
|
124 | 127 | throw new RuntimeException(ex);
|
| 128 | + } catch (JsonParsingException ex) { |
| 129 | + sendError("Unparseable request", response, ctx, requestedCharset); |
125 | 130 | }
|
126 | 131 | }
|
127 | 132 |
|
@@ -299,6 +304,21 @@ private String getAllowedMethods() {
|
299 | 304 | }
|
300 | 305 | }
|
301 | 306 |
|
| 307 | + private void sendError(String errorMessage, HttpServerResponse response, |
| 308 | + RoutingContext ctx, String requestedCharset) { |
| 309 | + VertxExecutionResponseWriter writer = new VertxExecutionResponseWriter(response, ctx, requestedCharset); |
| 310 | + GraphQLError error = GraphqlErrorBuilder |
| 311 | + .newError() |
| 312 | + .message(errorMessage) |
| 313 | + .build(); |
| 314 | + ExecutionResult executionResult = ExecutionResultImpl |
| 315 | + .newExecutionResult() |
| 316 | + .addError(error) |
| 317 | + .build(); |
| 318 | + ExecutionResponse executionResponse = new ExecutionResponse(executionResult); |
| 319 | + writer.write(executionResponse); |
| 320 | + } |
| 321 | + |
302 | 322 | private void doRequest(JsonObject jsonInput, HttpServerResponse response, RoutingContext ctx,
|
303 | 323 | String requestedCharset) {
|
304 | 324 | VertxExecutionResponseWriter writer = new VertxExecutionResponseWriter(response, ctx, requestedCharset);
|
|
0 commit comments