jon         01/03/12 13:35:57

  Modified:    src/java/org/apache/velocity/anakia AnakiaTask.java
  Log:
  improved the error reporting. when a parser error happens it now
  gives the information provided by the parser. this makes it easier
  to track down where the error is in the .xml file.
  
  example output looks like this:
  
  Error: The element type "p" must be terminated by the matching end-tag "</p>".
         Line: 251 Column: 15
  
  -jon
  
  Revision  Changes    Path
  1.19      +20 -3     
jakarta-velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java
  
  Index: AnakiaTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AnakiaTask.java   2001/03/12 04:47:07     1.18
  +++ AnakiaTask.java   2001/03/12 21:35:55     1.19
  @@ -66,6 +66,8 @@
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.taskdefs.MatchingTask;
   
  +import org.xml.sax.SAXParseException;
  +
   import org.jdom.Document;
   import org.jdom.Element;
   import org.jdom.JDOMException;
  @@ -90,7 +92,7 @@
    * <a href="http://jakarta.apache.org/velocity/anakia.html">Website</a>.
    *   
    * @author <a href="[EMAIL PROTECTED]">Jon S. Stevens</a>
  - * @version $Id: AnakiaTask.java,v 1.18 2001/03/12 04:47:07 jon Exp $
  + * @version $Id: AnakiaTask.java,v 1.19 2001/03/12 21:35:55 jon Exp $
    */
   public class AnakiaTask extends MatchingTask
   {
  @@ -390,16 +392,31 @@
           }
           catch (JDOMException e)
           {
  +            if (outFile != null ) outFile.delete();
               if (e.getRootCause() != null)
               {
  -                e.getRootCause().printStackTrace();
  +                Throwable rootCause = e.getRootCause();
  +                if (rootCause instanceof SAXParseException)
  +                {
  +                    System.out.println("");
  +                         System.out.println("Error: " + rootCause.getMessage());
  +                         System.out.println(
  +                             "       Line: " + 
  +                                 ((SAXParseException)rootCause).getLineNumber() + 
  +                             " Column: " + 
  +                                 ((SAXParseException)rootCause).getColumnNumber());
  +                    System.out.println("");
  +                }
  +                else
  +                {
  +                    rootCause.printStackTrace();
  +                }
               }
               else
               {
                   e.printStackTrace();
               }
   //            log("Failed to process " + inFile, Project.MSG_INFO);
  -            if (outFile != null ) outFile.delete();
           }
           catch (Throwable e)
           {
  
  
  

Reply via email to