Added more info to an unexpected YangModelException. 98/39798/1
authorDavid M. Karr <davidmichaelkarr@gmail.com>
Thu, 2 Jun 2016 21:24:11 +0000 (14:24 -0700)
committerDavid M. Karr <davidmichaelkarr@gmail.com>
Thu, 2 Jun 2016 21:24:11 +0000 (14:24 -0700)
Change-Id: Ieccdbd65b93098fb250fc9c4718d35b41d368a9f
Signed-off-by: David M. Karr <davidmichaelkarr@gmail.com>
plugins/org.opendaylight.yangide.core/src/org/opendaylight/yangide/core/model/YangElement.java

index ba791243c5001438b8cc82edc135d2fd7366441a..0f63b9a0d989cac361211a304ccae493e3946494 100644 (file)
@@ -213,7 +213,17 @@ public abstract class YangElement implements IOpenable, IBufferChangedListener {
             if (status.getException() != null) {
                 throw new YangModelException(status.getException(), status.getCode());
             } else {
-                throw new YangModelException(status.getMessage());
+                // The message can often just be "does not exist", which is extraordinarily
+                // unhelpful, so add info about the resource in question.
+                StringBuilder   sb  = new StringBuilder(status.getMessage());
+                if (underlResource != null) {
+                    sb.append(": name[").append(underlResource.getName()).
+                        append("] fullpath[").append(underlResource.getFullPath()).append("]");
+                }
+                else {
+                    sb.append(": Underlying resource is null.");
+                }
+                throw new YangModelException(sb.toString());
             }
         }