You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2021/01/14 17:01:09 UTC

[sling-org-apache-sling-jcr-resource] branch master updated: SLING-10063 improve exception messages (#13)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git


The following commit(s) were added to refs/heads/master by this push:
     new 18edb8d  SLING-10063 improve exception messages (#13)
18edb8d is described below

commit 18edb8d7e7106c1e1e3333b89bf4d2a49c686e3b
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Jan 14 18:01:02 2021 +0100

    SLING-10063 improve exception messages (#13)
---
 .../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..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 @@ 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("Property '" + key + "' can't be removed from node '" + getNodePath(node) + "'.", re);
         }
 
         return oldValue;