mirror of https://github.com/apache/maven.git
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:
parent
eb1e9b7316
commit
e1fe63e664
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
|
|
||||
-->
|
||||
|
|
Loading…
Reference in New Issue