You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by lt...@apache.org on 2005/10/01 16:29:58 UTC

svn commit: r292988 - /maven/maven-1/plugins/trunk/plugin/src/main/org/apache/maven/JaxpMsvBean.java

Author: ltheussl
Date: Sat Oct  1 07:29:57 2005
New Revision: 292988

URL: http://svn.apache.org/viewcvs?rev=292988&view=rev
Log:
Improve error handling

Modified:
    maven/maven-1/plugins/trunk/plugin/src/main/org/apache/maven/JaxpMsvBean.java

Modified: maven/maven-1/plugins/trunk/plugin/src/main/org/apache/maven/JaxpMsvBean.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/plugin/src/main/org/apache/maven/JaxpMsvBean.java?rev=292988&r1=292987&r2=292988&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/plugin/src/main/org/apache/maven/JaxpMsvBean.java (original)
+++ maven/maven-1/plugins/trunk/plugin/src/main/org/apache/maven/JaxpMsvBean.java Sat Oct  1 07:29:57 2005
@@ -53,9 +53,13 @@
     private Log log = LogFactory.getLog(JaxpMsvBean.class);
 
     private static String EMPTY = "";
-    private static ByteArrayInputStream bais =
+    private static ByteArrayInputStream EMPTY_STREAM =
         new ByteArrayInputStream(EMPTY.getBytes());
 
+    private static int MSV_WARNING = 0;
+    private static int MSV_ERROR = 1;
+    private static int MSV_FATAL_ERROR = 2;
+
     //~ Methods --------------------------------------------------------------
 
     /**
@@ -72,16 +76,16 @@
             boolean isValid = true;
             public void warning(SAXParseException e) throws SAXException
             {
-                log.warn(e);
+                errorMessage(e, MSV_WARNING);
             }
             public void error(SAXParseException e) throws SAXException
             {
-                log.error(e);
+                errorMessage(e, MSV_ERROR);
                 isValid = false;
             }
             public void fatalError(SAXParseException e) throws SAXException
             {
-                log.error(e);
+                errorMessage(e, MSV_FATAL_ERROR);
                 isValid = false;
             }
             public InputSource resolveEntity(String publicId,
@@ -89,7 +93,7 @@
             {
                 log.warn("WARNING: External entity " + systemId
                     + " won't be resolved!");
-                return new InputSource(bais);
+                return new InputSource(EMPTY_STREAM);
             }
             public void endDocument()
             {
@@ -103,6 +107,28 @@
         });
     }
 
+    private void errorMessage(SAXParseException e, int type)
+    {
+        File xmlFile = new File(file);
+
+        if (type == MSV_ERROR)
+        {
+            log.error( "com.sun.msv.verifier.ValidityViolation on line "
+                + e.getLineNumber() + " of " + xmlFile.getName() + ":" );
+            log.error( e.getMessage() );
+        } else if (type == MSV_FATAL_ERROR)
+        {
+            log.error( "Non-recoverable parsing error on line "
+                + e.getLineNumber() + " of " + xmlFile.getName() + ":" );
+            log.error( e.getMessage() );
+        } else if (type == MSV_WARNING)
+        {
+            log.warn( "Warning on line "
+                + e.getLineNumber() + " of " + xmlFile.getName() + ":" );
+            log.warn( e.getMessage() );
+        }
+    }
+
     /**
      * Sets the schema.
      *
@@ -143,6 +169,5 @@
       return file;
     }
 
-  
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org