From 3f4eea469ce0fe5f138dae6a459cb394980845c0 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 25 Oct 2011 01:10:49 +0200 Subject: [PATCH] better failure message if a type parser is not found with dynamic tempaltes --- .../index/mapper/object/RootObjectMapper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java index d4e1e391eed..1f8509cae3d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/object/RootObjectMapper.java @@ -207,7 +207,12 @@ public class RootObjectMapper extends ObjectMapper { return null; } Mapper.TypeParser.ParserContext parserContext = context.docMapperParser().parserContext(); - return parserContext.typeParser(dynamicTemplate.mappingType(dynamicType)).parse(name, dynamicTemplate.mappingForName(name, dynamicType), parserContext); + String mappingType = dynamicTemplate.mappingType(dynamicType); + Mapper.TypeParser typeParser = parserContext.typeParser(mappingType); + if (typeParser == null) { + throw new MapperParsingException("failed to find type parsed [" + mappingType + "] for [" + name + "]"); + } + return typeParser.parse(name, dynamicTemplate.mappingForName(name, mappingType), parserContext); } public DynamicTemplate findTemplate(ContentPath path, String name, String dynamicType) {