SLING-10063 improve exception messages
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java b/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java
index a6d3734..37467ab 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java
@@ -455,13 +455,21 @@
node.setProperty(name, entry.convertToType(Value.class, node, this.helper.getDynamicClassLoader()));
}
} catch (final RepositoryException re) {
- throw new IllegalArgumentException("Value for key " + key + " can't be put into node: " + value, re);
+ throw new IllegalArgumentException("Value '"+ value + "' for property '" + key + "' can't be put into node '" + getNodePath(node) + "'.", re);
}
this.valueCache.put(key, value);
return oldValue;
}
+ static String getNodePath(Node node) {
+ try {
+ return node.getPath();
+ } catch (RepositoryException e) {
+ return "Could not get node path: "+ e.getMessage();
+ }
+ }
+
/**
* @see java.util.Map#putAll(java.util.Map)
*/
@@ -492,7 +500,7 @@
node.getProperty(name).remove();
}
} catch (final RepositoryException re) {
- throw new IllegalArgumentException("Value for key " + key + " can't be removed from node.", re);
+ throw new IllegalArgumentException("Property '" + key + "' can't be removed from node '" + getNodePath(node) + "'.", re);
}
return oldValue;