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.mapper.FieldMapper;
import org.elasticsearch.index.mapper.FieldMapperListener;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.MergeMappingException;
import java.io.IOException;
@ -277,6 +278,7 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
}
@Override public void parse(ParseContext context) throws IOException {
try {
Fieldable field = parseCreateField(context);
if (field == null) {
return;
@ -287,6 +289,9 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
if (context.listener().beforeFieldAdded(this, field, context)) {
context.doc().add(field);
}
} catch (Exception e) {
throw new MapperParsingException("Failed to parse [" + names.fullName() + "]", e);
}
}
protected abstract Fieldable parseCreateField(ParseContext context) throws IOException;