better exception message when failing to parse a specific field

This commit is contained in:
kimchy 2010-07-15 18:46:12 +03:00
parent ca8ad83092
commit ee60d7dedc
1 changed files with 14 additions and 9 deletions

View File

@ -31,6 +31,7 @@ import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.index.field.data.FieldData; import org.elasticsearch.index.field.data.FieldData;
import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.FieldMapperListener; import org.elasticsearch.index.mapper.FieldMapperListener;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.MergeMappingException; import org.elasticsearch.index.mapper.MergeMappingException;
import java.io.IOException; import java.io.IOException;
@ -277,15 +278,19 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
} }
@Override public void parse(ParseContext context) throws IOException { @Override public void parse(ParseContext context) throws IOException {
Fieldable field = parseCreateField(context); try {
if (field == null) { Fieldable field = parseCreateField(context);
return; if (field == null) {
} return;
field.setOmitNorms(omitNorms); }
field.setOmitTermFreqAndPositions(omitTermFreqAndPositions); field.setOmitNorms(omitNorms);
field.setBoost(boost); field.setOmitTermFreqAndPositions(omitTermFreqAndPositions);
if (context.listener().beforeFieldAdded(this, field, context)) { field.setBoost(boost);
context.doc().add(field); if (context.listener().beforeFieldAdded(this, field, context)) {
context.doc().add(field);
}
} catch (Exception e) {
throw new MapperParsingException("Failed to parse [" + names.fullName() + "]", e);
} }
} }