Print out available augmentations 38/100938/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 3 May 2022 14:43:32 +0000 (16:43 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 3 May 2022 14:52:33 +0000 (16:52 +0200)
We seem to be facing a weird failure to look up augmentations, make
sure we report what is available.

Change-Id: Ifd9d27175bc90abfbba1a5e60935dc41cb01fc16
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/stream/YangInstanceIdentifierWriter.java

index 37c0b033533d825c328923afabf9ea2b7f442167..03588ede79e7a0a06a483c8652f27055971b8c47 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.data.api.schema.stream;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
@@ -257,12 +258,14 @@ public final class YangInstanceIdentifierWriter implements AutoCloseable {
 
     private static AugmentationSchemaNode enterAugmentation(final AugmentationTarget target,
             final AugmentationIdentifier id) throws IOException {
-        for (var augment : target.getAvailableAugmentations()) {
+        final var augs = target.getAvailableAugmentations();
+        for (var augment : augs) {
             if (id.equals(augmentationIdentifierFrom(augment))) {
                 return augment;
             }
         }
-        throw new IOException("Cannot find augmentation " + id + " in " + target);
+        throw new IOException("Cannot find augmentation " + id + " in " + target + ", available: "
+            + Collections2.transform(augs, YangInstanceIdentifierWriter::augmentationIdentifierFrom));
     }
 
     // FIXME: duplicate of data.util.DataSchemaContextNode.augmentationIdentifierFrom()