Better error logging in DistributedDynamicConfigStore

- constant for built-in resourceId

Change-Id: If36e2e3023b0bd3068ecc75d54d263be0b2410b6
diff --git a/apps/config/src/main/java/org/onosproject/config/FailedException.java b/apps/config/src/main/java/org/onosproject/config/FailedException.java
index fcd2847..0115c33 100644
--- a/apps/config/src/main/java/org/onosproject/config/FailedException.java
+++ b/apps/config/src/main/java/org/onosproject/config/FailedException.java
@@ -38,4 +38,14 @@
     public FailedException(String message) {
         super(message);
     }
+
+    /**
+     * Constructs a new runtime exception with the given error message.
+     *
+     * @param message error message
+     * @param cause cause
+     */
+    public FailedException(String message, Throwable cause) {
+        super(message, cause);
+    }
 }
\ No newline at end of file
diff --git a/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java b/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
index 8a84f06..48b370d 100644
--- a/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
+++ b/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
@@ -132,7 +132,7 @@
         }
         if (spath.compareTo(ResourceIdParser.ROOT) != 0) {
             if (completeVersioned(keystore.get(DocumentPath.from(spath))) == null) {
-                throw new FailedException("Node or parent doesnot exist");
+                throw new FailedException("Node or parent does not exist for " + spath);
             }
         }
         spath = ResourceIdParser.appendNodeKey(spath, node.key());
@@ -215,8 +215,9 @@
         CompletableFuture<Versioned<DataNode.Type>> ret = keystore.get(dpath);
         type = completeVersioned(ret);
         if (type == null) {
-            throw new FailedException("Requested node or some of the parents" +
-                                              "are not present in the requested path");
+            throw new FailedException("Requested node or some of the parents " +
+                                      "are not present in the requested path: " +
+                                      spath);
         }
         DataNode retVal = null;
         if (type == DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE) {
@@ -486,20 +487,15 @@
             return future.get();
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
-            if (e == null) {
-                throw new FailedException("Unknown Exception");
-            } else {
-                throw new FailedException(e.getCause().getMessage());
-            }
+            throw new FailedException(e.getCause().getMessage());
         } catch (ExecutionException e) {
-            if (e == null) {
-                throw new FailedException("Unknown Exception");
-            } else if (e.getCause() instanceof IllegalDocumentModificationException) {
-                throw new FailedException("Node or parent doesnot exist or is root or is not a Leaf Node");
+            if (e.getCause() instanceof IllegalDocumentModificationException) {
+                throw new FailedException("Node or parent doesnot exist or is root or is not a Leaf Node",
+                                          e.getCause());
             } else if (e.getCause() instanceof NoSuchDocumentPathException) {
-                throw new FailedException("Resource id does not exist");
+                throw new FailedException("Resource id does not exist", e.getCause());
             } else {
-                throw new FailedException("Datastore operation failed");
+                throw new FailedException("Datastore operation failed", e.getCause());
             }
         }
     }
diff --git a/apps/config/src/main/java/org/onosproject/d/config/DeviceResourceIds.java b/apps/config/src/main/java/org/onosproject/d/config/DeviceResourceIds.java
index a49c6fc..605ae63 100644
--- a/apps/config/src/main/java/org/onosproject/d/config/DeviceResourceIds.java
+++ b/apps/config/src/main/java/org/onosproject/d/config/DeviceResourceIds.java
@@ -68,6 +68,12 @@
             .addBranchPointSchema(ROOT_NAME, DCS_NAMESPACE)
             .build();
 
+    public static final ResourceId DEVICES_ID = ResourceId.builder()
+            .addBranchPointSchema(ROOT_NAME, DCS_NAMESPACE)
+            .addBranchPointSchema(DEVICES_NAME, DCS_NAMESPACE)
+            .build();
+
+
     static final NodeKey<?> ROOT_NODE =
             NodeKey.builder().schemaId(ROOT_NAME, DCS_NAMESPACE).build();