Improve error message when child schema not found 44/37044/2
authorTom Pantelis <tpanteli@brocade.com>
Mon, 4 Apr 2016 00:03:15 +0000 (20:03 -0400)
committerRobert Varga <nite@hq.sk>
Tue, 19 Apr 2016 16:03:12 +0000 (16:03 +0000)
In AbstractNodeContainerModificationStrategy, added the parent id to the
error messages to provide more context for troubleshooting.

Change-Id: I87fe94b8eab35f50de022db3406b14e667ad691e
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractNodeContainerModificationStrategy.java

index c6190f1cbc311d0c13422ebf859f148ac8fb1208..4a1e598e42bb0a3fefc71387017c09f5ccfabd03 100644 (file)
@@ -53,12 +53,14 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
                     childOp.get().verifyStructure(castedChild, verifyChildren);
                 } else {
                     throw new SchemaValidationFailedException(String.format(
-                            "Child %s is not valid child according to schema.", castedChild.getIdentifier()));
+                            "Node %s is not a valid child of %s according to the schema.",
+                            castedChild.getIdentifier(), container.getIdentifier()));
                 }
             }
         }
     }
 
+    @Override
     protected void recursivelyVerifyStructure(NormalizedNode<?, ?> value) {
         final NormalizedNodeContainer container = (NormalizedNodeContainer) value;
         for (final Object child : container.getValue()) {
@@ -69,7 +71,8 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
                 childOp.get().recursivelyVerifyStructure(castedChild);
             } else {
                 throw new SchemaValidationFailedException(
-                        String.format("Child %s is not valid child according to schema.", castedChild.getIdentifier()));
+                        String.format("Node %s is not a valid child of %s according to the schema.",
+                                castedChild.getIdentifier(), container.getIdentifier()));
             }
         }
     }