You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/02/06 13:38:11 UTC

[maven-doxia] 01/01: [DOXIA-645] Clean up exceptions

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch DOXIA-645
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 63843f67324e2db7753179d92a5f63608442f42c
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Feb 6 14:38:00 2022 +0100

    [DOXIA-645] Clean up exceptions
    
    This closes #94
---
 .../org/apache/maven/doxia/index/IndexEntry.java   |  2 +-
 .../apache/maven/doxia/macro/AbstractMacro.java    |  3 ++
 .../maven/doxia/macro/MacroExecutionException.java | 12 ++++++++
 .../maven/doxia/macro/snippet/SnippetMacro.java    |  4 +--
 .../org/apache/maven/doxia/macro/toc/TocMacro.java |  2 +-
 .../maven/doxia/parser/AbstractXmlParser.java      | 11 +++----
 .../apache/maven/doxia/parser/ParseException.java  | 35 +++++++++++++++-------
 .../doxia/sink/impl/AbstractTextSinkFactory.java   |  6 ++--
 .../maven/doxia/sink/impl/AbstractXmlSink.java     | 12 +++-----
 .../maven/doxia/sink/impl/Xhtml5BaseSink.java      | 11 ++-----
 .../maven/doxia/sink/impl/XhtmlBaseSink.java       | 11 ++-----
 .../maven/doxia/util/ByLineReaderSource.java       | 13 ++++----
 .../org/apache/maven/doxia/util/HtmlTools.java     |  2 +-
 .../org/apache/maven/doxia/util/LineBreaker.java   |  2 +-
 .../org/apache/maven/doxia/util/XmlValidator.java  |  2 +-
 .../maven/doxia/sink/impl/AbstractXmlSinkTest.java |  4 +--
 .../maven/doxia/sink/impl/SinkEventElement.java    |  6 ++--
 .../maven/doxia/xsd/AbstractXmlValidatorTest.java  |  2 +-
 .../maven/doxia/module/apt/AptParseException.java  | 13 +++++++-
 .../apache/maven/doxia/module/apt/AptParser.java   |  4 +--
 .../maven/doxia/module/apt/AptReaderSource.java    |  2 +-
 .../apache/maven/doxia/module/fml/FmlParser.java   |  2 +-
 .../apache/maven/doxia/module/xdoc/XdocParser.java |  2 +-
 .../maven/doxia/module/xhtml/XhtmlParser.java      |  2 +-
 .../maven/doxia/module/xhtml5/Xhtml5Parser.java    |  2 +-
 25 files changed, 94 insertions(+), 73 deletions(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java b/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
index d0e4b9e..4353613 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
@@ -261,7 +261,7 @@ public class IndexEntry
         }
         else if ( entries.size() > 1 )
         {
-            throw new RuntimeException( "This index has more than one root entry" );
+            throw new IllegalStateException( "This index has more than one root entry" );
         }
         else
         {
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/AbstractMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/AbstractMacro.java
index 4374846..fc59162 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/AbstractMacro.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/AbstractMacro.java
@@ -21,6 +21,7 @@ package org.apache.maven.doxia.macro;
 
 import java.util.Map;
 
+import org.apache.commons.lang3.Validate;
 import org.apache.maven.doxia.sink.SinkEventAttributes;
 import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
 import org.codehaus.plexus.util.StringUtils;
@@ -41,7 +42,9 @@ public abstract class AbstractMacro
      * @param paramName The name of the parameter to check.
      * @param paramValue The parameter value.
      * @since 1.1
+     * @deprecated Not used, use {@link Validate}
      */
+    @Deprecated
     protected void required( String paramName, String paramValue )
     {
         if ( StringUtils.isEmpty( paramValue ) )
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroExecutionException.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroExecutionException.java
index 1aec3e7..429ef71 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroExecutionException.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/MacroExecutionException.java
@@ -32,6 +32,18 @@ public class MacroExecutionException
     static final long serialVersionUID = -6314856898570018814L;
 
     /**
+     * Construct a new <code>MacroExecutionException</code> with the specified cause.
+     *
+     * @param cause the cause. This can be retrieved later by the
+     * <code>Throwable.getCause()</code> method. (A null value is permitted, and indicates
+     * that the cause is nonexistent or unknown.)
+     */
+    public MacroExecutionException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    /**
      * Construct a new <code>MacroExecutionException</code> with the specified detail message.
      *
      * @param message The detailed message.
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
index e69744f..d9c31dd 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
@@ -118,7 +118,7 @@ public class SnippetMacro
             }
             catch ( MalformedURLException e )
             {
-                throw new IllegalArgumentException( urlParam + " is a malformed URL" );
+                throw new IllegalArgumentException( urlParam + " is a malformed URL", e );
             }
         }
         else if ( !StringUtils.isEmpty( fileParam ) )
@@ -136,7 +136,7 @@ public class SnippetMacro
             }
             catch ( MalformedURLException e )
             {
-                throw new IllegalArgumentException( fileParam + " is a malformed URL" );
+                throw new IllegalArgumentException( fileParam + " is a malformed URL", e );
             }
         }
         else
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java
index 2b94937..4c676cd 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java
@@ -117,7 +117,7 @@ public class TocMacro
         }
         catch ( ParseException e )
         {
-            throw new MacroExecutionException( "ParseException: " + e.getMessage(), e );
+            throw new MacroExecutionException( e );
         }
 
         if ( index.getChildEntries().size() > 0 )
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
index 10fd1d5..61363bb 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
@@ -110,7 +110,7 @@ public abstract class AbstractXmlParser
             }
             catch ( IOException e )
             {
-                throw new ParseException( "Error reading the model: " + e.getMessage(), e );
+                throw new ParseException( "Error reading the model", e );
             }
 
             new XmlValidator( ).validate( content );
@@ -133,12 +133,12 @@ public abstract class AbstractXmlParser
         }
         catch ( XmlPullParserException ex )
         {
-            throw new ParseException( "Error parsing the model: " + ex.getMessage(), ex, ex.getLineNumber(),
+            throw new ParseException( "Error parsing the model", ex, ex.getLineNumber(),
                                       ex.getColumnNumber() );
         }
         catch ( MacroExecutionException ex )
         {
-            throw new ParseException( "Macro execution failed: " + ex.getMessage(), ex );
+            throw new ParseException( "Macro execution failed", ex );
         }
 
         setSecondParsing( false );
@@ -265,6 +265,7 @@ public abstract class AbstractXmlParser
             }
             catch ( IOException io )
             {
+                // Does not have a cause arg
                 throw new XmlPullParserException( "IOException: " + io.getMessage(), parser, io );
             }
         }
@@ -770,7 +771,7 @@ public abstract class AbstractXmlParser
             }
             catch ( IOException e )
             {
-                throw new SAXException( "IOException: " + e.getMessage(), e );
+                throw new SAXException( e );
             }
             finally
             {
@@ -802,7 +803,7 @@ public abstract class AbstractXmlParser
             }
             catch ( IOException e )
             {
-                throw new SAXException( "IOException: " + e.getMessage(), e );
+                throw new SAXException( e );
             }
             finally
             {
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java
index 1db3051..ed294c6 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/ParseException.java
@@ -41,6 +41,19 @@ public class ParseException
     private int columnNumber;
 
     /**
+     * Construct a new <code>ParseException</code> with the specified cause.
+     * <br>
+     * <b>Note</b>: no line or column number will be used.
+     *
+     * @param e the cause. This can be retrieved later by the <code>Throwable.getCause()</code> method.
+     * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
+     */
+    public ParseException( Exception e )
+    {
+        this( null, e, null, -1, -1 );
+    }
+
+    /**
      * Construct a new <code>ParseException</code> with the specified detail message.
      * <br>
      * <b>Note</b>: no line or column number will be used.
@@ -50,7 +63,7 @@ public class ParseException
      */
     public ParseException( String message )
     {
-        this( null, message, null, -1, -1 );
+        this( message, null, null, -1, -1 );
     }
 
     /**
@@ -65,7 +78,7 @@ public class ParseException
      */
     public ParseException( String message, Exception e )
     {
-        this( e, message, null, -1, -1 );
+        this( message, e, null, -1, -1 );
     }
 
     /**
@@ -82,7 +95,7 @@ public class ParseException
      */
     public ParseException( String message, int line, int column )
     {
-        this( null, message, null, line, column );
+        this( message, null, null, line, column );
     }
 
     /**
@@ -101,7 +114,7 @@ public class ParseException
      */
     public ParseException( String message, Exception e, int line, int column )
     {
-        this( e, message, null, line, column );
+        this( message, e, null, line, column );
     }
 
     /**
@@ -118,7 +131,7 @@ public class ParseException
      */
     public ParseException( Exception e, int line, int column )
     {
-        this( e, null, null, line, column );
+        this( null, e, null, line, column );
     }
 
     /**
@@ -136,28 +149,28 @@ public class ParseException
      */
     public ParseException( Exception e, String file, int line, int column )
     {
-        this( e, null, file, line, column );
+        this( null, e, file, line, column );
     }
 
     /**
      * Construct a new <code>ParseException</code> with the specified cause, detail message,
      * filename, line number and column number.
-     *
-     * @param e the cause. This can be retrieved later by the <code>Throwable.getCause()</code> method.
-     * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
      * @param message The detailed message.
      * This can later be retrieved by the <code>Throwable.getMessage()</code> method.
+     * @param e the cause. This can be retrieved later by the <code>Throwable.getCause()</code> method.
+     * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
      * @param file Name of a file that couldn't be parsed.
      * This can later be retrieved by the getFileName() method.
      * @param line The line number where the parsing failed.
      * This can later be retrieved by the getLineNumber() method.
      * @param column The column number where the parsing failed.
      * This can later be retrieved by the getColumnNumber() method.
+     *
      * @since 1.1
      */
-    public ParseException( Exception e, String message, String file, int line, int column )
+    public ParseException( String message, Exception e, String file, int line, int column )
     {
-        super( ( message == null ) ? ( ( e == null ) ? null : e.getMessage() ) : message, e );
+        super( message, e );
 
         this.fileName = file;
         this.lineNumber = line;
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractTextSinkFactory.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractTextSinkFactory.java
index e07979e..3f7acb3 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractTextSinkFactory.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractTextSinkFactory.java
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.util.Objects;
 
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkFactory;
@@ -60,10 +61,7 @@ public abstract class AbstractTextSinkFactory
     public Sink createSink( File outputDir, String outputName, String encoding )
         throws IOException
     {
-        if ( outputDir == null )
-        {
-            throw new IllegalArgumentException( "outputDir cannot be null." );
-        }
+        Objects.requireNonNull( outputDir, "outputDir cannot be null" );
 
         if ( !outputDir.exists() )
         {
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractXmlSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractXmlSink.java
index c4292c1..5dbb559 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractXmlSink.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractXmlSink.java
@@ -19,6 +19,8 @@ package org.apache.maven.doxia.sink.impl;
  * under the License.
  */
 
+import java.util.Objects;
+
 import javax.swing.text.MutableAttributeSet;
 import javax.swing.text.html.HTML.Tag;
 
@@ -114,10 +116,7 @@ public abstract class AbstractXmlSink
      */
     protected void writeStartTag( Tag t, MutableAttributeSet att, boolean isSimpleTag )
     {
-        if ( t == null )
-        {
-            throw new IllegalArgumentException( "A tag is required" );
-        }
+        Objects.requireNonNull( t, "t cannot be null" );
 
         StringBuilder sb = new StringBuilder();
 
@@ -165,10 +164,7 @@ public abstract class AbstractXmlSink
      */
     protected void writeEndTag( Tag t )
     {
-        if ( t == null )
-        {
-            throw new IllegalArgumentException( "A tag is required" );
-        }
+        Objects.requireNonNull( t, "t cannot be null" );
 
         StringBuilder sb = new StringBuilder();
         sb.append( LESS_THAN );
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
index 36f944e..b4bdee0 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
@@ -29,6 +29,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Stack;
 
 import javax.swing.text.MutableAttributeSet;
@@ -1734,10 +1735,7 @@ public class Xhtml5BaseSink
     @Override
     public void anchor( String name, SinkEventAttributes attributes )
     {
-        if ( name == null )
-        {
-            throw new NullPointerException( "Anchor name cannot be null!" );
-        }
+        Objects.requireNonNull( name, "name cannot be null" );
 
         if ( headFlag )
         {
@@ -1813,10 +1811,7 @@ public class Xhtml5BaseSink
      */
     private void link( String href, String target, MutableAttributeSet attributes )
     {
-        if ( href == null )
-        {
-            throw new NullPointerException( "Link name cannot be null!" );
-        }
+        Objects.requireNonNull( href, "href cannot be null" );
 
         if ( headFlag )
         {
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java
index f3d595b..e4318f7 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSink.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Stack;
 
 import javax.swing.text.MutableAttributeSet;
@@ -1611,10 +1612,7 @@ public class XhtmlBaseSink
     @Override
     public void anchor( String name, SinkEventAttributes attributes )
     {
-        if ( name == null )
-        {
-            throw new NullPointerException( "Anchor name cannot be null!" );
-        }
+        Objects.requireNonNull( name, "name cannot be null" );
 
         if ( headFlag )
         {
@@ -1690,10 +1688,7 @@ public class XhtmlBaseSink
      */
     private void link( String href, String target, MutableAttributeSet attributes )
     {
-        if ( href == null )
-        {
-            throw new NullPointerException( "Link name cannot be null!" );
-        }
+        Objects.requireNonNull( href, "href cannot be null" );
 
         if ( headFlag )
         {
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/util/ByLineReaderSource.java b/doxia-core/src/main/java/org/apache/maven/doxia/util/ByLineReaderSource.java
index 7d06f98..ec5ce1b 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/util/ByLineReaderSource.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/util/ByLineReaderSource.java
@@ -27,6 +27,7 @@ package org.apache.maven.doxia.util;
 import java.io.IOException;
 import java.io.LineNumberReader;
 import java.io.Reader;
+import java.util.Objects;
 
 import org.apache.maven.doxia.parser.ParseException;
 import org.codehaus.plexus.util.IOUtil;
@@ -56,7 +57,7 @@ public class ByLineReaderSource implements ByLineSource
      * called
      */
     private boolean ungetted = false;
-    
+
     private String name;
 
     /**
@@ -68,7 +69,7 @@ public class ByLineReaderSource implements ByLineSource
     {
         this( in, "" );
     }
-    
+
     /**
      * <p>Constructor for ByLineReaderSource.</p>
      *
@@ -78,7 +79,7 @@ public class ByLineReaderSource implements ByLineSource
     public ByLineReaderSource( final Reader in, final String name )
     {
         this.reader = new LineNumberReader( in );
-        
+
         this.name = name;
 
         this.lineNumber = -1;
@@ -172,10 +173,8 @@ public class ByLineReaderSource implements ByLineSource
     /** {@inheritDoc} */
     public final void unget( final String s )
     {
-        if ( s == null )
-        {
-            throw new IllegalArgumentException( "argument can't be null" );
-        }
+        Objects.requireNonNull( s, "s cannot be null" );
+
         if ( s.length() != 0 )
         {
             ungetLine();
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java b/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java
index deeaacd..4a10ace 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java
@@ -453,7 +453,7 @@ public class HtmlTools
     {
         if ( !isValidCodePoint( codePoint ) )
         {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException( "Code point " + codePoint + " is not valid" );
         }
 
         if ( isSupplementaryCodePoint( codePoint ) )
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java b/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java
index d5c5dfb..6a0898e 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java
@@ -71,7 +71,7 @@ public class LineBreaker
     {
         if ( max <= 0 )
         {
-            throw new IllegalArgumentException( "maxLineLength <= 0" );
+            throw new IllegalArgumentException( "max must be a positive integer" );
         }
 
         destination = out;
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/util/XmlValidator.java b/doxia-core/src/main/java/org/apache/maven/doxia/util/XmlValidator.java
index f57264f..10cd906 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/util/XmlValidator.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/util/XmlValidator.java
@@ -97,7 +97,7 @@ public class XmlValidator
         }
         catch ( IOException | SAXException e )
         {
-            throw new ParseException( "Error validating the model: " + e.getMessage(), e );
+            throw new ParseException( "Error validating the model", e );
         }
     }
 
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java
index 7752110..a6d9613 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java
@@ -67,7 +67,7 @@ public class AbstractXmlSinkTest
             instance.writeStartTag( null );
             fail( "null tag should fail!" );
         }
-        catch ( IllegalArgumentException e )
+        catch ( NullPointerException e )
         {
             assertNotNull( e );
         }
@@ -77,7 +77,7 @@ public class AbstractXmlSinkTest
             instance.writeEndTag( null );
             fail( "null tag should fail!" );
         }
-        catch ( IllegalArgumentException e )
+        catch ( NullPointerException e )
         {
             assertNotNull( e );
         }
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventElement.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventElement.java
index 73cd4a9..5cf4a45 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventElement.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventElement.java
@@ -20,6 +20,7 @@ package org.apache.maven.doxia.sink.impl;
  */
 
 import java.util.Arrays;
+import java.util.Objects;
 
 /**
  * A single sink event, used for testing purposes in order to check
@@ -45,10 +46,7 @@ public class SinkEventElement
      */
     public SinkEventElement( String name, Object[] arguments )
     {
-        if ( name == null )
-        {
-            throw new NullPointerException( "Element name can't be null!" );
-        }
+        Objects.requireNonNull( name, "name cannot be null" );
 
         this.methodName = name;
         this.args = arguments;
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java
index db1fe0f..f6c2fb8 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java
@@ -141,7 +141,7 @@ public abstract class AbstractXmlValidatorTest
 
             if ( testJar == null )
             {
-                throw new RuntimeException(
+                throw new IllegalStateException(
                         "Could not find the Doxia test documents artefact i.e. doxia-test-docs-XXX.jar" );
             }
         }
diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java
index 0df36e1..858176e 100644
--- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java
+++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java
@@ -33,6 +33,17 @@ public class AptParseException
     static final long serialVersionUID = 1694654412921168623L;
 
     /**
+     * Construct a new AptParseException with the cause.
+     *
+     * @param e the cause. This can be retrieved later by the <code>Throwable.getCause()</code> method.
+     * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
+     */
+    public AptParseException( Exception e )
+    {
+        super( e );
+    }
+
+    /**
      * Construct a new AptParseException with the specified detail message.
      *
      * @param message The detailed message.
@@ -73,7 +84,7 @@ public class AptParseException
      */
     public AptParseException( String message, Exception e, String name, int line, int column )
     {
-        super( e, message, name, line, column );
+        super( message, e, name, line, column );
     }
 
     /**
diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
index fec38c0..003b4fa 100644
--- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
+++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
@@ -204,7 +204,7 @@ public class AptParser
         }
         catch ( IOException e )
         {
-            throw new AptParseException( "IOException: " + e.getMessage(), e );
+            throw new AptParseException( e );
         }
 
         try
@@ -237,7 +237,7 @@ public class AptParser
         catch ( AptParseException ape )
         {
             // TODO handle column number
-            throw new AptParseException( ape.getMessage(), ape, getSourceName(), getSourceLineNumber(), -1 );
+            throw new AptParseException( null, ape, getSourceName(), getSourceLineNumber(), -1 );
         }
         finally
         {
diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptReaderSource.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptReaderSource.java
index 8edf7b3..975cef4 100644
--- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptReaderSource.java
+++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptReaderSource.java
@@ -97,7 +97,7 @@ public class AptReaderSource
         catch ( IOException e )
         {
             // TODO handle column number
-            throw new AptParseException( "IOException: " + e.getMessage(), e, lineNumber, -1 );
+            throw new AptParseException( null, e, lineNumber, -1 );
         }
 
         return line;
diff --git a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
index a7a6223..70874cd 100644
--- a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
+++ b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
@@ -101,7 +101,7 @@ public class FmlParser
         }
         catch ( IOException ex )
         {
-            throw new ParseException( "Error reading the input source: " + ex.getMessage(), ex );
+            throw new ParseException( "Error reading the input source", ex );
         }
         finally
         {
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
index 82edd20..196e700 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
@@ -101,7 +101,7 @@ public class XdocParser
         }
         catch ( IOException ex )
         {
-            throw new ParseException( "Error reading the input source: " + ex.getMessage(), ex );
+            throw new ParseException( "Error reading the input source", ex );
         }
         finally
         {
diff --git a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
index 1d19043..bb3c328 100644
--- a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
+++ b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
@@ -344,7 +344,7 @@ public class XhtmlParser
         }
         catch ( IOException ex )
         {
-            throw new ParseException( "Error reading the input source: " + ex.getMessage(), ex );
+            throw new ParseException( "Error reading the input source", ex );
         }
         finally
         {
diff --git a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
index 46887af..e38f1c2 100644
--- a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
+++ b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
@@ -345,7 +345,7 @@ public class Xhtml5Parser
         }
         catch ( IOException ex )
         {
-            throw new ParseException( "Error reading the input source: " + ex.getMessage(), ex );
+            throw new ParseException( "Error reading the input source", ex );
         }
         finally
         {