Skip to content

Commit

Permalink
Map ParsingException to HTTP Bad Request
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Nov 28, 2024
1 parent 826ae9d commit 7d1b217
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7d1b217

Please sign in to comment.