Adding error diagnoser for MojoExecutionExceptions.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@312976 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-10-11 23:21:51 +00:00
parent eb1e9b7316
commit e1fe63e664
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package org.apache.maven.usability;
import org.apache.maven.plugin.MojoExecutionException;
public class MojoExecutionExceptionDiagnoser
implements ErrorDiagnoser
{
public boolean canDiagnose( Throwable error )
{
return DiagnosisUtils.containsInCausality( error, MojoExecutionException.class );
}
public String diagnose( Throwable error )
{
MojoExecutionException mee = (MojoExecutionException) DiagnosisUtils.getFromCausality( error, MojoExecutionException.class );
StringBuffer message = new StringBuffer();
message.append( "Error executing mojo: " ).append( mee.getSource() ).append( "\n\n" );
message.append( mee.getLongMessage() ).append( "\n\n" );
Throwable root = DiagnosisUtils.getRootCause( mee );
if ( root != null && root != mee )
{
message.append( "Root Cause: " ).append( root.getMessage() ).append( "\n\n" );
}
return message.toString();
}
}

View File

@ -93,6 +93,16 @@
</component>
<!--
|
|MojoExecutionExceptionDiagnoser
|
-->
<component>
<role>org.apache.maven.usability.ErrorDiagnoser</role>
<role-hint>MojoExecutionExceptionDiagnoser</role-hint>
<implementation>org.apache.maven.usability.MojoExecutionExceptionDiagnoser</implementation>
</component>
<!--
|
|ProjectBuildDiagnoser
|
-->