Improve error message when the cluster has no indices

When the indices are empty, replaced the error message `IndexMissingException[[[]] missing]` with `IndexMissingException[[[_all]] missing]`

Closes elastic/elasticsearch#138

Original commit: elastic/x-pack-elasticsearch@b590547722
This commit is contained in:
javanna 2014-10-09 16:32:01 +02:00 committed by Luca Cavanna
parent 7f77627396
commit c20e4efe2d
1 changed files with 3 additions and 0 deletions

View File

@ -71,6 +71,9 @@ public class DefaultIndicesResolver implements IndicesResolver<TransportRequest>
//If we can't replace because we got an empty set, we can only throw exception.
//Downside of this is that a single item exception is going to its composite requests fail as a whole.
if (indices == null || indices.isEmpty()) {
if (MetaData.isAllIndices(indicesRequest.indices())) {
throw new IndexMissingException(new Index(MetaData.ALL));
}
throw new IndexMissingException(new Index(Arrays.toString(indicesRequest.indices())));
}
((IndicesRequest.Replaceable)indicesRequest).indices(indices.toArray(new String[indices.size()]));