Discern exceptions when building LeafRefContext 98/71798/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 4 May 2018 13:03:33 +0000 (15:03 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 4 May 2018 13:04:49 +0000 (15:04 +0200)
IOExceptions are unexpected and result in an IllegalStateException,
while LeafRefYangSyntaxErrorException indicates an inconsistent
schema context, hence results in an IllegalArgumentException.

Change-Id: I5282dc964f64af7a46794e3a02e219358fd95285
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefContext.java

index 0e403563129e847a73f7e0daa5933368e4329d0c..7c0572049336a30e61ad74fa7b20084a5bb0cb37 100644 (file)
@@ -51,8 +51,10 @@ public final class LeafRefContext {
     public static LeafRefContext create(final SchemaContext ctx) {
         try {
             return new LeafRefContextTreeBuilder(ctx).buildLeafRefContextTree();
-        } catch (IOException | LeafRefYangSyntaxErrorException e) {
-            throw new RuntimeException(e);
+        } catch (LeafRefYangSyntaxErrorException e) {
+            throw new IllegalArgumentException(e);
+        } catch (IOException e) {
+            throw new IllegalStateException(e);
         }
     }