presto-main/src/main/java/io/prestosql/server/ThrowableMapper.java/ThrowableMapper/toResponse
class ThrowableMapper:    @Override
    public Response toResponse(Throwable throwable)
    {
        if (throwable instanceof WebApplicationException) {
            return ((WebApplicationException) throwable).getResponse();
        }

        log.warn(throwable, "Request failed for %s", request.getRequestURI());

        ResponseBuilder responseBuilder = Response.serverError()
                .header(CONTENT_TYPE, TEXT_PLAIN);
        if (includeExceptionInResponse) {
            responseBuilder.entity(Throwables.getStackTraceAsString(throwable));
        }
        else {
            responseBuilder.entity("Exception processing request");
        }
        return responseBuilder.build();
    }