Improve error message 59/9959/1
authorRobert Varga <rovarga@cisco.com>
Thu, 14 Aug 2014 21:03:29 +0000 (23:03 +0200)
committerRobert Varga <rovarga@cisco.com>
Thu, 14 Aug 2014 21:03:29 +0000 (23:03 +0200)
This fixes the errors reported by default in the log by formatting the
message.

Change-Id: I5c971844ceb9f140ea62fda4472899971689c98f
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NormalizedNodeContainerModificationStrategy.java

index 1a2d8f88e52694ae701c4377284c4cc7f8cb6b68..6a7d67e3ad15e41b668808663cd12b10d50a0a0c 100644 (file)
@@ -166,17 +166,14 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp
     @Override
     protected void checkSubtreeModificationApplicable(final YangInstanceIdentifier path, final NodeModification modification,
             final Optional<TreeNode> current) throws DataValidationFailedException {
-        checkDoesNotExists(path, modification.getOriginal().isPresent() || current.isPresent(), "Node does not exist. Could not modify its children.");
+        if (!modification.getOriginal().isPresent() && !current.isPresent()) {
+            throw new ModifiedNodeDoesNotExistException(path, String.format("Node %s does not exist. Cannot apply modification to its children.", path));
+        }
+
         SchemaAwareApplyOperation.checkConflicting(path, current.isPresent(), "Node was deleted by other transaction.");
         checkChildPreconditions(path, modification, current);
     }
 
-    private static void checkDoesNotExists(final YangInstanceIdentifier path, final boolean condition, final String message) throws DataValidationFailedException {
-        if(!condition) {
-            throw new ModifiedNodeDoesNotExistException(path,message);
-        }
-    }
-
     private void checkChildPreconditions(final YangInstanceIdentifier path, final NodeModification modification, final Optional<TreeNode> current) throws DataValidationFailedException {
         final TreeNode currentMeta = current.get();
         for (NodeModification childMod : modification.getChildren()) {