Skip to content

Commit

Permalink
Use response status 500 if search failed but wasn't syntax error
Browse files Browse the repository at this point in the history
Closes #3026

(cherry picked from commit 652421c)
  • Loading branch information
joschi authored and Jochen Schalanda committed Nov 2, 2016
1 parent e84d3eb commit a6a0ac2
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -57,6 +57,8 @@
import javax.inject.Inject;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.ForbiddenException;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -246,7 +248,7 @@ protected ChunkedOutput<ScrollResult.ScrollChunk> buildChunkedOutput(final Scrol
return output;
}

protected BadRequestException createRequestExceptionForParseFailure(String query, SearchPhaseExecutionException e) {
protected WebApplicationException createRequestExceptionForParseFailure(String query, SearchPhaseExecutionException e) {
LOG.warn("Unable to execute search: {}", e.getMessage());

QueryParseError errorMessage = QueryParseError.create(query, "Unable to execute search", e.getClass().getCanonicalName());
Expand Down Expand Up @@ -297,12 +299,14 @@ protected BadRequestException createRequestExceptionForParseFailure(String query
parseException.getClass().getCanonicalName());
}
}
}

return new BadRequestException(Response
.status(Response.Status.BAD_REQUEST)
.entity(errorMessage)
.build());
} else {
return new InternalServerErrorException("Unable to fulfill search request", e);
}
}

public void checkSearchPermission(String filter, String searchPermission) {
Expand Down

0 comments on commit a6a0ac2

Please sign in to comment.