Update of /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ant/modulesbuilder
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18699/xdoclet/core/src/xdoclet/ant/modulesbuilder

Modified Files:
        ModuleXmlParser.java ModulesGrandBuilderTask.java 
Log Message:
If module.xml is not found in the module or the module.xml file can not be
parsed, then tell the problematic module and throw a runtime exception so that
the user can correct the error instead of having kilometers of exceptions 
bubble up.
See XDT-1429.

Index: ModuleXmlParser.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/ant/modulesbuilder/ModuleXmlParser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ModuleXmlParser.java        5 Sep 2002 06:55:40 -0000       1.2
--- ModuleXmlParser.java        7 Jun 2005 07:46:57 -0000       1.3
***************
*** 42,46 ****
      }
  
!     public Module parse(InputStream in)
      {
          try {
--- 42,46 ----
      }
  
!     public Module parse(InputStream in) throws SAXException
      {
          try {
***************
*** 72,76 ****
          catch (SAXException e) {
              module = null;
!             e.printStackTrace();
          }
          return module;
--- 72,76 ----
          catch (SAXException e) {
              module = null;
!             throw e;
          }
          return module;

Index: ModulesGrandBuilderTask.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/ant/modulesbuilder/ModulesGrandBuilderTask.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** ModulesGrandBuilderTask.java        6 Sep 2004 05:16:09 -0000       1.13
--- ModulesGrandBuilderTask.java        7 Jun 2005 07:46:57 -0000       1.14
***************
*** 21,24 ****
--- 21,25 ----
  import org.apache.tools.ant.types.Path;
  import org.apache.tools.ant.types.XMLCatalog;
+ import org.xml.sax.SAXException;
  
  /**
***************
*** 164,168 ****
                  Module module = createModule(file);
  
!                 modules.put(module.getName(), module);
              }
          }
--- 165,170 ----
                  Module module = createModule(file);
  
!                 if (module != null)
!                     modules.put(module.getName(), module);
              }
          }
***************
*** 322,325 ****
--- 324,333 ----
      }
  
+     /**
+      * Parse the modules.xml file in the passed directory
+      *
+      * @param file  a file system path for a directory containing a module.xml
+      * @return      a new Module if successful, null otherwise
+      */
      private Module createModule(File file)
      {
***************
*** 335,347 ****
              }
              catch (FileNotFoundException e) {
!                 e.printStackTrace();
              }
          }
          else {
!             module = new Module();
          }
  
!         module.setName(file.getName());
!         module.setBaseDir(file);
  
          return module;
--- 343,362 ----
              }
              catch (FileNotFoundException e) {
!                 log("File not found: " + file.getAbsolutePath() + 
"/module.xml", Project.MSG_ERR);
!             }
!             catch (SAXException e) {
!                 log("SAX Exception in " + file.getAbsolutePath() + 
"/module.xml", Project.MSG_ERR);
              }
          }
          else {
!             log("File not found: " + file.getAbsolutePath() + "/module.xml", 
Project.MSG_ERR);
          }
  
!         if (module != null) {
!             module.setName(file.getName());
!             module.setBaseDir(file);
!         }
!         else
!             throw new RuntimeException("Can not continue. Please correct 
above error.");
  
          return module;



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
xdoclet-devel mailing list
xdoclet-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to