Bug 4540: Yang parser exceptions should follow consistent path
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / ImportEffectiveStatementImpl.java
index 9839ca4f1bc630ab8ce93abe2ce4524702b6932d..03fde57ee243baae7c91f5b6d64f0483fbb23fdf 100644 (file)
@@ -12,9 +12,10 @@ import java.util.Objects;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.MissingSubstatementException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
-public class ImportEffectiveStatementImpl extends EffectiveStatementBase<String, ImportStatement> implements
+public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ImportStatement> implements
         ModuleImport {
 
     private final String moduleName;
@@ -33,7 +34,8 @@ public class ImportEffectiveStatementImpl extends EffectiveStatementBase<String,
         if (prefixStmt != null ) {
             this.prefix = prefixStmt.argument();
         } else {
-            throw new IllegalStateException("Prefix is mandatory substatement of import statement");
+            throw new MissingSubstatementException("Prefix is mandatory substatement of import statement",
+                    ctx.getStatementSourceReference());
         }
     }