Author: brett Date: Sat Apr 1 21:52:05 2006 New Revision: 390780 URL: http://svn.apache.org/viewcvs?rev=390780&view=rev Log: [MSITE-105] correct issues with presenting line number where errors occur Submitted by Jesse McConnell
Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java?rev=390780&r1=390779&r2=390780&view=diff ============================================================================== --- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java (original) +++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParseException.java Sat Apr 1 21:52:05 2006 @@ -21,15 +21,38 @@ public class AptParseException extends ParseException { + /** + * @deprecated source isn't a safe place to get linenumbers from + * @param message + * @param source + */ public AptParseException( String message, AptSource source ) { super( null, message, source.getName(), source.getLineNumber() ); } + /** + * @deprecated source isn't a safe place to get linenumbers from + * @param message + * @param source + * @param e + */ public AptParseException( String message, AptSource source, Exception e ) { super( e, message, source.getName(), source.getLineNumber() ); } + + + public AptParseException( String message, String name, int lineNumber, Exception e) + { + super( e, message, name, lineNumber); + } + + public AptParseException( String message, Exception e ) + { + super( message, e ); + } + public AptParseException( String message ) { Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java?rev=390780&r1=390779&r2=390780&view=diff ============================================================================== --- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java (original) +++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java Sat Apr 1 21:52:05 2006 @@ -101,27 +101,34 @@ public void parse( Reader source, Sink sink ) throws AptParseException { - this.source = new AptReaderSource( source ); + try + { + this.source = new AptReaderSource( source ); - this.sink = sink; + this.sink = sink; - blockFileName = null; + blockFileName = null; - blockLineNumber = -1; + blockLineNumber = -1; - // Lookahead line. - nextLine(); + // Lookahead line. + nextLine(); - // Lookahead block. - nextBlock( /*first*/ true ); + // Lookahead block. + nextBlock( /*first*/ true ); - traverseHead(); + traverseHead(); - traverseBody(); + traverseBody(); - this.source = null; + this.source = null; - this.sink = null; + this.sink = null; + } + catch ( AptParseException ape ) + { + throw new AptParseException( ape.getMessage(), getSourceName(), getSourceLineNumber(), ape ); + } } public String getSourceName() @@ -768,8 +775,7 @@ if ( blockType != type ) { throw new AptParseException( - "expected " + typeNames[type] + ", found " + typeNames[blockType] + " at line " + getSourceLineNumber(), - source ); + "expected " + typeNames[type] + ", found " + typeNames[blockType] ); } } @@ -2139,11 +2145,11 @@ } catch ( MacroExecutionException e ) { - throw new AptParseException( "Unable to execute macro in the APT document", source, e ); + throw new AptParseException( "Unable to execute macro in the APT document", e ); } catch ( MacroNotFoundException e ) { - throw new AptParseException( "Unable to find macro used in the APT document", source, e ); + throw new AptParseException( "Unable to find macro used in the APT document", e ); } } } Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java?rev=390780&r1=390779&r2=390780&view=diff ============================================================================== --- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java (original) +++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java Sat Apr 1 21:52:05 2006 @@ -242,7 +242,7 @@ } catch ( ParseException e ) { - getLogger().error( "Error parsing " + fullPathDoc + ": " + e.getMessage(), e ); + getLogger().error( "Error parsing " + fullPathDoc + ": line [" + e.getLineNumber() + "] " + e.getMessage() , e ); } finally {