Introduce formatting methods for SourceException
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / ImportEffectiveStatementImpl.java
index 82435f3c4f613288a985f422c4ee40b6743086c8..d9f6fb6b2ca9141ca630b97267520513b5532712 100644 (file)
@@ -12,6 +12,7 @@ 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 DeclaredEffectiveStatementBase<String, ImportStatement> implements
@@ -30,10 +31,11 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase
         this.revision = (revisionDateStmt == null) ? SimpleDateFormatUtil.DEFAULT_DATE_IMP : revisionDateStmt.argument();
 
         PrefixEffectiveStatementImpl prefixStmt = firstEffective(PrefixEffectiveStatementImpl.class);
-        if (prefixStmt != null ) {
+        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());
         }
     }