fix failed tests due to wrapping failures with mapping parsing exception

This commit is contained in:
Shay Banon 2012-12-26 15:59:07 -08:00
parent 7a0404ac35
commit ef55e4feec
4 changed files with 12 additions and 7 deletions

View File

@ -524,6 +524,11 @@ public class DocumentMapper implements ToXContent {
context.newObjectMappers().mappers.clear();
}
// if its already a mapper parsing exception, no need to wrap it...
if (e instanceof MapperParsingException) {
throw (MapperParsingException) e;
}
throw new MapperParsingException("failed to parse", e);
} finally {
// only close the parser when its not provided externally

View File

@ -23,7 +23,7 @@ import org.elasticsearch.rest.RestStatus;
/**
*/
public class StrictDynamicMappingException extends MapperException {
public class StrictDynamicMappingException extends MapperParsingException {
public StrictDynamicMappingException(String path, String fieldName) {
super("mapping set to strict, dynamic introduction of [" + fieldName + "] within [" + path + "] is not allowed");

View File

@ -354,7 +354,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
context.doc().add(field);
}
} catch (Exception e) {
throw new MapperParsingException("Failed to parse [" + names.fullName() + "]", e);
throw new MapperParsingException("failed to parse [" + names.fullName() + "]", e);
}
}

View File

@ -20,10 +20,10 @@
package org.elasticsearch.test.unit.index.mapper.geo;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.common.Numbers;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.search.geo.GeoHashUtils;
import org.elasticsearch.test.unit.index.mapper.MapperTests;
@ -93,7 +93,7 @@ public class LatLonMappingGeoPointTests {
.endObject()
.bytes());
assert false;
} catch (ElasticSearchIllegalArgumentException e) {
} catch (MapperParsingException e) {
}
@ -104,7 +104,7 @@ public class LatLonMappingGeoPointTests {
.endObject()
.bytes());
assert false;
} catch (ElasticSearchIllegalArgumentException e) {
} catch (MapperParsingException e) {
}
@ -115,7 +115,7 @@ public class LatLonMappingGeoPointTests {
.endObject()
.bytes());
assert false;
} catch (ElasticSearchIllegalArgumentException e) {
} catch (MapperParsingException e) {
}
@ -126,7 +126,7 @@ public class LatLonMappingGeoPointTests {
.endObject()
.bytes());
assert false;
} catch (ElasticSearchIllegalArgumentException e) {
} catch (MapperParsingException e) {
}
}