DATACMNS-283 - MappingInstantiationException captures more context now.

If an exception occurs in ReflectionEntityInstantiator we now capture more context about the failed instantiation.
This commit is contained in:
Oliver Gierke
2013-02-15 18:34:56 +01:00
parent e093aead13
commit 0aef8c60b7
3 changed files with 145 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ package org.springframework.data.convert;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.BeanInstantiationException;
@@ -60,7 +61,7 @@ public enum ReflectionEntityInstantiator implements EntityInstantiator {
return BeanUtils.instantiateClass(entity.getType());
}
} catch (BeanInstantiationException e) {
throw new MappingInstantiationException(e.getMessage(), e);
new MappingInstantiationException(entity, Collections.emptyList(), e);
}
}
@@ -74,7 +75,7 @@ public enum ReflectionEntityInstantiator implements EntityInstantiator {
try {
return BeanUtils.instantiateClass(constructor.getConstructor(), params.toArray());
} catch (BeanInstantiationException e) {
throw new MappingInstantiationException(e.getMessage(), e);
throw new MappingInstantiationException(entity, params, e);
}
}
}