Throw ParsingExceptions instead of IllegalArgument
... keeps track of the position of the error.
This commit is contained in:
parent
fb647e9bf4
commit
744de1f6cb
|
@ -21,6 +21,7 @@ package org.elasticsearch.search.sort;
|
|||
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.lucene.BytesRefs;
|
||||
|
@ -305,7 +306,7 @@ public class FieldSortBuilder extends SortBuilder<FieldSortBuilder> implements S
|
|||
if (context.parseFieldMatcher().match(currentFieldName, NESTED_FILTER)) {
|
||||
nestedFilter = context.parseInnerQueryBuilder();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected " + NESTED_FILTER.getPreferredName() + " element.");
|
||||
throw new ParsingException(parser.getTokenLocation(), "Expected " + NESTED_FILTER.getPreferredName() + " element.");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if (context.parseFieldMatcher().match(currentFieldName, NESTED_PATH)) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.search.sort;
|
||||
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
|
@ -85,6 +86,8 @@ public abstract class AbstractSortTestCase<T extends SortBuilder & SortBuilderPa
|
|||
builder.endObject();
|
||||
|
||||
XContentParser itemParser = XContentHelper.createParser(builder.bytes());
|
||||
ParsingException except = new ParsingException(itemParser.getTokenLocation(), "mytext", itemParser.getTokenLocation());
|
||||
System.out.println(except.getMessage());
|
||||
itemParser.nextToken();
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue