You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ah...@apache.org on 2006/09/12 15:02:36 UTC
svn commit: r442578 - in /maven/maven-1/core/trunk/src:
java/org/apache/maven/ java/org/apache/maven/cli/
java/org/apache/maven/werkz/ messages/
Author: aheritier
Date: Tue Sep 12 06:02:36 2006
New Revision: 442578
URL: http://svn.apache.org/viewvc?view=rev&rev=442578
Log:
J2SE1.4 is required for m1.1.
Replace our custom chaining exceptions by the one of the J2SE.
Better handle them by displaying the stack of error messages.
Modified:
maven/maven-1/core/trunk/src/java/org/apache/maven/MavenException.java
maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java
maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java
maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoActionDefinitionException.java
maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoSuchGoalException.java
maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/UnattainableGoalException.java
maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/WerkzException.java
maven/maven-1/core/trunk/src/messages/messages.properties
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/MavenException.java
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/MavenException.java?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/MavenException.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/MavenException.java Tue Sep 12 06:02:36 2006
@@ -30,15 +30,13 @@
extends Exception
{
- /** Exception that might have caused this one. */
- private Throwable cause;
-
/**
* Creates a new instance of <code>MavenException</code> without detail
* message.
*/
public MavenException()
{
+ super();
}
/**
@@ -63,8 +61,7 @@
*/
public MavenException( String message, Throwable cause )
{
- super( message );
- this.cause = cause;
+ super( message, cause );
}
/**
@@ -75,8 +72,7 @@
*/
public MavenException( Throwable cause )
{
- super( cause.toString() );
- this.cause = cause;
+ super( cause );
}
/**
@@ -87,56 +83,6 @@
*/
public Throwable getException()
{
- return cause;
- }
-
- /**
- * Prints the stack trace for this exception and any
- * nested exception to <code>System.err</code>.
- */
- public void printStackTrace()
- {
- printStackTrace( System.err );
+ return getCause();
}
-
- /**
- * Prints the stack trace of this exception and any nested
- * exception to the specified PrintStream.
- *
- * @param ps The PrintStream to print the stack trace to.
- * Must not be <code>null</code>.
- */
- public void printStackTrace( PrintStream ps )
- {
- synchronized ( ps )
- {
- super.printStackTrace( ps );
- if ( cause != null )
- {
- ps.println( "--- Nested Exception ---" );
- cause.printStackTrace( ps );
- }
- }
- }
-
- /**
- * Prints the stack trace of this exception and any nested
- * exception to the specified PrintWriter.
- *
- * @param pw The PrintWriter to print the stack trace to.
- * Must not be <code>null</code>.
- */
- public void printStackTrace( PrintWriter pw )
- {
- synchronized ( pw )
- {
- super.printStackTrace( pw );
- if ( cause != null )
- {
- pw.println( "--- Nested Exception ---" );
- cause.printStackTrace( pw );
- }
- }
- }
-
}
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java Tue Sep 12 06:02:36 2006
@@ -145,7 +145,7 @@
}
catch ( MavenException e )
{
- throw new MavenException( e.getMessage(), e );
+ throw e;
}
catch ( Exception e )
{
@@ -181,7 +181,7 @@
* @throws IOException when resolving file names and paths
*/
public static Project getNonJellyProject( File projectDescriptor, MavenJellyContext parentContext,
- boolean useParentPom )
+ boolean useParentPom )
throws MavenException, IOException
{
// 1)
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java Tue Sep 12 06:02:36 2006
@@ -559,13 +559,13 @@
catch ( UnsatisfiedDependencyException e )
{
failed = true;
- LOGGER.error( e.getLocalizedMessage() );
+ displayThrowable( e );
returnCode = RC_FAILED_DEPENDENCY;
}
catch ( ChecksumVerificationException e )
{
failed = true;
- LOGGER.error( e.getLocalizedMessage() );
+ displayThrowable( e );
returnCode = RC_FAILED_DEPENDENCY;
}
catch ( UnknownGoalException e )
@@ -579,14 +579,14 @@
{
failed = true;
LOGGER.error( MavenUtils.getMessage( "build.failed" ) );
- LOGGER.error( e.getMessage() );
LOGGER.error( MavenUtils.getMessage( "build.noSuchGoalException" ) );
+ displayThrowable( e );
returnCode = RC_NO_GOAL;
}
catch ( RepoConfigException e )
{
failed = true;
- LOGGER.error( e.getLocalizedMessage() );
+ displayThrowable( e );
returnCode = RC_BAD_REPO;
}
catch ( NoActionDefinitionException e )
@@ -619,19 +619,13 @@
int lineNumber = e.getLineNumber();
int column = e.getColumnNumber();
- String msg = e.getReason();
-
LOGGER.error( MavenUtils.getMessage( "build.jellyException.file", fileName ) );
LOGGER.error( MavenUtils.getMessage( "build.jellyException.element", elementName ) );
LOGGER.error( MavenUtils.getMessage( "build.jellyException.line", new Integer( lineNumber ) ) );
LOGGER.error( MavenUtils.getMessage( "build.jellyException.column", new Integer( column ) ) );
- LOGGER.error( msg );
+ displayThrowable( e );
- if ( getCli().hasOption( DISPLAY_STACKTRACE ) )
- {
- e.printStackTrace();
- }
displayBugReportHelp();
}
catch ( MavenException e )
@@ -639,12 +633,8 @@
returnCode = RC_OTHER_FAILURE;
failed = true;
LOGGER.error( MavenUtils.getMessage( "build.failed" ) );
- LOGGER.error( e.getMessage() );
- if ( getCli().hasOption( DISPLAY_STACKTRACE ) )
- {
- e.printStackTrace();
- }
- else
+ displayThrowable( e );
+ if ( !getCli().hasOption( DISPLAY_STACKTRACE ) )
{
LOGGER.error( MavenUtils.getMessage( "displayBugReportHelp.line4" ) );
}
@@ -657,7 +647,7 @@
{
returnCode = RC_OTHER_FAILURE;
failed = true;
- t.printStackTrace();
+ displayThrowable( t );
displayBugReportHelp();
}
@@ -889,6 +879,27 @@
{
printConsoleMavenHeader();
exit( RC_OK );
+ }
+ }
+
+ /**
+ * Recursively display errors in the exceptions/throwables stack.
+ * @param t the exception or throwable to display ..
+ */
+ private void displayThrowable( Throwable t )
+ {
+ // For maven 1.1, J2SE 1.4 is required thus
+ // we can have recursively the rootCause of the throwable
+ Throwable localThrowable = t;
+ do
+ {
+ LOGGER.error( localThrowable.getLocalizedMessage() );
+ localThrowable = localThrowable.getCause();
+ }
+ while ( localThrowable != null );
+ if ( getCli().hasOption( DISPLAY_STACKTRACE ) )
+ {
+ LOGGER.error( MavenUtils.getMessage( "build.stacktrace" ),t );
}
}
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoActionDefinitionException.java
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoActionDefinitionException.java?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoActionDefinitionException.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoActionDefinitionException.java Tue Sep 12 06:02:36 2006
@@ -87,6 +87,7 @@
*/
public NoActionDefinitionException( Goal goal )
{
+ super();
this.goal = goal;
}
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoSuchGoalException.java
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoSuchGoalException.java?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoSuchGoalException.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/NoSuchGoalException.java Tue Sep 12 06:02:36 2006
@@ -89,6 +89,7 @@
*/
public NoSuchGoalException( String goalName )
{
+ super();
this.goalName = goalName;
}
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/UnattainableGoalException.java
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/UnattainableGoalException.java?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/UnattainableGoalException.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/UnattainableGoalException.java Tue Sep 12 06:02:36 2006
@@ -79,9 +79,6 @@
/** Name of goal in which an error occurred. */
private String goalName;
- /** Root exception. */
- private Throwable rootCause;
-
// ------------------------------------------------------------
// Constructors
// ------------------------------------------------------------
@@ -93,8 +90,8 @@
*/
public UnattainableGoalException( String goalName, Throwable rootCause )
{
+ super(rootCause);
this.goalName = goalName;
- this.rootCause = rootCause;
}
// ------------------------------------------------------------
@@ -116,19 +113,7 @@
*/
public Throwable getRootCause()
{
- return this.rootCause;
- }
-
- /** Print the stack-trace of this exception.
- */
- public void printStackTrace()
- {
- super.printStackTrace();
-
- if ( getRootCause() != null )
- {
- getRootCause().printStackTrace();
- }
+ return this.getCause();
}
public String getMessage()
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/WerkzException.java
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/WerkzException.java?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/WerkzException.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/werkz/WerkzException.java Tue Sep 12 06:02:36 2006
@@ -71,4 +71,37 @@
extends Exception
{
+ /**
+ *
+ */
+ public WerkzException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public WerkzException( String message, Throwable cause )
+ {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public WerkzException( String message )
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public WerkzException( Throwable cause )
+ {
+ super(cause);
+ }
+
}
Modified: maven/maven-1/core/trunk/src/messages/messages.properties
URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/messages/messages.properties?view=diff&rev=442578&r1=442577&r2=442578
==============================================================================
--- maven/maven-1/core/trunk/src/messages/messages.properties (original)
+++ maven/maven-1/core/trunk/src/messages/messages.properties Tue Sep 12 06:02:36 2006
@@ -51,6 +51,7 @@
build.final.memory=Final Memory : ${1}
build.total.time=Total time : ${1}
build.finished.time=Finished at : ${1}
+build.stacktrace=Exception stack traces :
displayBugReportHelp.line1=You have encountered an unknown error running Maven.
displayBugReportHelp.line2=Please help us to correct this problem by following these simple steps:
displayBugReportHelp.line3=- read the Maven FAQ at ${1}