LUCENE-4996: Include field name in all DocInverter exceptions

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1481080 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-05-10 16:29:19 +00:00
parent 08a140dcf5
commit afbca4dc8a
2 changed files with 7 additions and 4 deletions

View File

@ -126,6 +126,9 @@ Bug Fixes
* LUCENE-4993: Fix BeiderMorseFilter to preserve custom attributes when
inserting tokens with position increment 0. (Uwe Schindler)
* LUCENE-4996: Ensure DocInverterPerField always includes field name
in exception messages. (Markus Jelsma via Robert Muir)
Optimizations

View File

@ -119,10 +119,10 @@ final class DocInverterPerField extends DocFieldConsumerPerField {
final int posIncr = posIncrAttribute.getPositionIncrement();
if (posIncr < 0) {
throw new IllegalArgumentException("position increment must be >=0 (got " + posIncr + ")");
throw new IllegalArgumentException("position increment must be >=0 (got " + posIncr + ") for field '" + field.name() + "'");
}
if (fieldState.position == 0 && posIncr == 0) {
throw new IllegalArgumentException("first position increment must be > 0 (got 0)");
throw new IllegalArgumentException("first position increment must be > 0 (got 0) for field '" + field.name() + "'");
}
int position = fieldState.position + posIncr;
if (position > 0) {
@ -145,11 +145,11 @@ final class DocInverterPerField extends DocFieldConsumerPerField {
int endOffset = fieldState.offset + offsetAttribute.endOffset();
if (startOffset < 0 || endOffset < startOffset) {
throw new IllegalArgumentException("startOffset must be non-negative, and endOffset must be >= startOffset, "
+ "startOffset=" + startOffset + ",endOffset=" + endOffset);
+ "startOffset=" + startOffset + ",endOffset=" + endOffset + " for field '" + field.name() + "'");
}
if (startOffset < lastStartOffset) {
throw new IllegalArgumentException("offsets must not go backwards startOffset="
+ startOffset + " is < lastStartOffset=" + lastStartOffset);
+ startOffset + " is < lastStartOffset=" + lastStartOffset + " for field '" + field.name() + "'");
}
lastStartOffset = startOffset;
}