Add StatementSourceException
[yangtools.git] / parser / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / repo / YangTextSchemaContextResolver.java
index 06365a8cbf61ea4ce7589c717474839ef26f9fbb..42b839e1cc8b635ac08980538a938fc50ecd1f51 100644 (file)
@@ -338,14 +338,14 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
     }
 
     @Beta
-    public EffectiveModelContext trySchemaContext() throws SchemaResolutionException {
+    public EffectiveModelContext trySchemaContext() throws SchemaResolutionException, ExecutionException {
         return trySchemaContext(StatementParserMode.DEFAULT_MODE);
     }
 
     @Beta
     @SuppressWarnings("checkstyle:avoidHidingCauseException")
     public EffectiveModelContext trySchemaContext(final StatementParserMode statementParserMode)
-            throws SchemaResolutionException {
+            throws SchemaResolutionException, ExecutionException {
         final var future = repository
                 .createEffectiveModelContextFactory(config(statementParserMode, getSupportedFeatures()))
                 .createEffectiveModelContext(ImmutableSet.copyOf(requiredSources));
@@ -355,11 +355,10 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
         } catch (InterruptedException e) {
             throw new IllegalStateException("Interrupted while waiting for SchemaContext assembly", e);
         } catch (ExecutionException e) {
-            final var cause = e.getCause();
-            if (cause instanceof SchemaResolutionException resolutionException) {
-                throw resolutionException;
+            if (e.getCause() instanceof SchemaResolutionException sre) {
+                throw sre;
             }
-            throw new SchemaResolutionException("Failed to assemble SchemaContext", e);
+            throw e;
         }
     }