This is an automated email from the ASF dual-hosted git repository. kwin pushed a commit to branch feature/SLING-10063-improve-exception-msg in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git
commit 357362f1ec1551b84366cf38e547fc7405296b29 Author: Konrad Windszus <[email protected]> AuthorDate: Thu Jan 14 16:34:25 2021 +0100 SLING-10063 improve exception messages --- .../sling/jcr/resource/internal/JcrModifiableValueMap.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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..936404c 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 @@ public final class JcrModifiableValueMap 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 @@ public final class JcrModifiableValueMap 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("Value for property '" + key + "' can't be removed from node '" + getNodePath(node) + "'.", re); } return oldValue;
