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 / TypedefStatementImpl.java
index 3c06831867649a2fc8d00b0bcc082c9581f9b817..9d3fb3ef1ad936c0e8084c85d8860238852689d3 100644 (file)
@@ -69,8 +69,8 @@ public class TypedefStatementImpl extends AbstractDeclaredStatement<QName> imple
                 throws SourceException {
             if (stmt != null && stmt.getParentContext() != null) {
                 if (stmt.getParentContext().getFromNamespace(TypeNamespace.class, stmt.getStatementArgument()) != null) {
-                    throw new IllegalArgumentException(String.format("Duplicate name for typedef %s",
-                            stmt.getStatementArgument()));
+                    throw new SourceException(String.format("Duplicate name for typedef %s",
+                            stmt.getStatementArgument()), stmt.getStatementSourceReference());
                 }
 
                 stmt.getParentContext().addContext(TypeNamespace.class, stmt.getStatementArgument(), stmt);