From 7d1b2171a5487341cbe108d72488aff28fe3259a Mon Sep 17 00:00:00 2001 From: "Mateusz \"Serafin\" Gajewski" Date: Thu, 28 Nov 2024 10:58:57 +0100 Subject: [PATCH] Map ParsingException to HTTP Bad Request --- .../src/main/java/io/trino/server/ThrowableMapper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/trino-main/src/main/java/io/trino/server/ThrowableMapper.java b/core/trino-main/src/main/java/io/trino/server/ThrowableMapper.java index 1399e6d118f7..ef0331ff4f95 100644 --- a/core/trino-main/src/main/java/io/trino/server/ThrowableMapper.java +++ b/core/trino-main/src/main/java/io/trino/server/ThrowableMapper.java @@ -15,6 +15,7 @@ import com.google.common.base.Throwables; import com.google.inject.Inject; +import io.airlift.jaxrs.ParsingException; import jakarta.ws.rs.BadRequestException; import jakarta.ws.rs.ForbiddenException; import jakarta.ws.rs.InternalServerErrorException; @@ -83,6 +84,9 @@ public Response toResponse(Throwable throwable) case TimeoutException timeoutException -> plainTextError(Response.Status.REQUEST_TIMEOUT) .entity("Error 408 Timeout: " + timeoutException.getMessage()) .build(); + case ParsingException parsingException -> Response.status(Response.Status.BAD_REQUEST) + .entity(Throwables.getStackTraceAsString(parsingException)) + .build(); case WebApplicationException webApplicationException -> webApplicationException.getResponse(); default -> { ResponseBuilder responseBuilder = plainTextError(Response.Status.INTERNAL_SERVER_ERROR);