From 12aea1773c0c8e6a575c2549d30cae8b7f0e9f56 Mon Sep 17 00:00:00 2001 From: Jacob Bowers Date: Thu, 12 Mar 2015 21:39:05 -0400 Subject: [PATCH] Feature no. 1, "nicer exception" has been implemented --- .../action/search/type/TransportSearchHelper.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java index 500c2ab7dcc59..80fbd36d5b16a 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchHelper.java @@ -39,6 +39,7 @@ import org.elasticsearch.search.internal.ShardSearchTransportRequest; import java.io.IOException; +import java.util.Arrays; import java.util.Map; /** @@ -94,15 +95,16 @@ public static ParsedScrollId parseScrollId(String scrollId) { throw new ElasticsearchIllegalArgumentException("Failed to decode scrollId", e); } String[] elements = Strings.splitStringToArray(spare.get(), ';'); + System.out.println(Arrays.toString(elements)); if (elements.length < 2) { - throw new ElasticsearchIllegalArgumentException("Malformed scrollId [" + scrollId + "]"); + throw new ElasticsearchIllegalArgumentException("Malformed scrollId [" + scrollId + "], type and size parameters not provided"); } int index = 0; String type = elements[index++]; int contextSize = Integer.parseInt(elements[index++]); if (elements.length < contextSize + 2) { - throw new ElasticsearchIllegalArgumentException("Malformed scrollId [" + scrollId + "]"); + throw new ElasticsearchIllegalArgumentException("Malformed scrollId [" + scrollId + "], size is less than number of actual shards"); } @SuppressWarnings({"unchecked"}) Tuple[] context = new Tuple[contextSize]; @@ -110,7 +112,7 @@ public static ParsedScrollId parseScrollId(String scrollId) { String element = elements[index++]; int sep = element.indexOf(':'); if (sep == -1) { - throw new ElasticsearchIllegalArgumentException("Malformed scrollId [" + scrollId + "]"); + throw new ElasticsearchIllegalArgumentException("Malformed scrollId [" + scrollId + "], shard number is either missing or incorrectly separated from the ID"); } context[i] = new Tuple<>(element.substring(sep + 1), Long.parseLong(element.substring(0, sep))); }