better exception message when failing to parse a specific field
This commit is contained in:
parent
ca8ad83092
commit
ee60d7dedc
|
@ -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,6 +278,7 @@ 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 {
|
||||||
|
try {
|
||||||
Fieldable field = parseCreateField(context);
|
Fieldable field = parseCreateField(context);
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -287,6 +289,9 @@ public abstract class XContentFieldMapper<T> implements FieldMapper<T>, XContent
|
||||||
if (context.listener().beforeFieldAdded(this, field, context)) {
|
if (context.listener().beforeFieldAdded(this, field, context)) {
|
||||||
context.doc().add(field);
|
context.doc().add(field);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new MapperParsingException("Failed to parse [" + names.fullName() + "]", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Fieldable parseCreateField(ParseContext context) throws IOException;
|
protected abstract Fieldable parseCreateField(ParseContext context) throws IOException;
|
||||||
|
|
Loading…
Reference in New Issue