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

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git

commit 053dcf9db0046bacfe5b1b47a4842011de7128cf
Author: Hervé Boutemy <hbout...@apache.org>
AuthorDate: Mon Apr 16 23:54:57 2018 +0200

    [DOXIASITETOOLS-179] catch VelocityException instead of Exception
    
    and keep cause message to display parsing error location
---
 .../maven/doxia/siterenderer/DefaultSiteRenderer.java  | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git 
a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
 
b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
index a279e9e..13eea52 100644
--- 
a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
+++ 
b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
@@ -383,7 +383,7 @@ public class DefaultSiteRenderer
             // TODO: DOXIA-111: the filter used here must be checked generally.
             if ( docRenderingContext.getAttribute( "velocity" ) != null )
             {
-                getLogger().debug( "Processing Velocity for " + 
docRenderingContext.getInputName() );
+                getLogger().debug( "Processing Velocity for " + 
docRenderingContext.getDoxiaSourcePath() );
                 try
                 {
                     Context vc = createDocumentVelocityContext( 
docRenderingContext, siteContext );
@@ -402,16 +402,10 @@ public class DefaultSiteRenderer
 
                     reader = new StringReader( doxiaContent );
                 }
-                catch ( Exception e )
+                catch ( VelocityException e )
                 {
-                    if ( getLogger().isDebugEnabled() )
-                    {
-                        getLogger().error( "Error parsing " + resource + " as 
a velocity template, using as text.", e );
-                    }
-                    else
-                    {
-                        getLogger().error( "Error parsing " + resource + " as 
a velocity template, using as text." );
-                    }
+                    throw new RendererException( "Error parsing " + 
docRenderingContext.getDoxiaSourcePath()
+                        + " as a Velocity template: " + e.getMessage(), e );
                 }
 
                 if ( parser.getType() == Parser.XML_TYPE && 
siteContext.isValidate() )
@@ -439,10 +433,6 @@ public class DefaultSiteRenderer
             }
             sink.enableLogging( new PlexusLoggerWrapper( getLogger() ) );
 
-            if ( reader == null ) // can happen if velocity throws above
-            {
-                throw new RendererException( "Error getting a parser for '" + 
doc + "'" );
-            }
             doxia.parse( reader, docRenderingContext.getParserId(), sink );
         }
         catch ( ParserNotFoundException e )

-- 
To stop receiving notification emails like this one, please contact
hbout...@apache.org.

Reply via email to