Permalink
Browse files

throwing more detailed exception when setting entity property fails

  • Loading branch information...
1 parent e349142 commit 9f44c3d73abb718ffbd94936b618e1e25db1e33e @musketyr musketyr committed Sep 13, 2013
Showing with 16 additions and 4 deletions.
  1. +16 −4 core/src/main/groovyx/gaelyk/datastore/DatastoreEntityCoercion.java
@@ -38,11 +38,23 @@ public static Entity convert(DatastoreEntity<?> dsEntity){
entity = new Entity(kind);
}
- for(String propertyName : dsEntity.getDatastoreIndexedProperties()){
- entity.setProperty(propertyName, transformValueForStorage(dsEntity.getProperty(propertyName)));
+ for (String propertyName : dsEntity.getDatastoreIndexedProperties()) {
+ Object value = dsEntity.getProperty(propertyName);
+ try {
+ entity.setProperty(propertyName, transformValueForStorage(dsEntity.getProperty(propertyName)));
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Problem setting value '" + value + "' to indexed property '" + propertyName + "' of entity "
+ + dsEntity.getClass().getSimpleName(), e);
+ }
}
- for(String propertyName : dsEntity.getDatastoreUnindexedProperties()){
- entity.setUnindexedProperty(propertyName, transformValueForStorage(dsEntity.getProperty(propertyName)));
+ for (String propertyName : dsEntity.getDatastoreUnindexedProperties()) {
+ Object value = dsEntity.getProperty(propertyName);
+ try {
+ entity.setUnindexedProperty(propertyName, transformValueForStorage(value));
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Problem setting value '" + value + "' to unindexed property '" + propertyName + "' of entity "
+ + dsEntity.getClass().getSimpleName(), e);
+ }
}
return entity;

0 comments on commit 9f44c3d

Please sign in to comment.