mirror of https://github.com/apache/maven.git
Adding conditional logic to pull out root cause to a couple diagnosers.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@320918 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7a1e687879
commit
ed17ce3aba
|
@ -21,6 +21,8 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
|||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ArtifactResolverDiagnoser
|
||||
implements ErrorDiagnoser
|
||||
{
|
||||
|
@ -42,6 +44,13 @@ public class ArtifactResolverDiagnoser
|
|||
message.append( "Failed to resolve artifact." );
|
||||
message.append( "\n\n" );
|
||||
message.append( exception.getMessage() );
|
||||
|
||||
IOException ioe = (IOException) DiagnosisUtils.getFromCausality( exception, IOException.class );
|
||||
|
||||
if ( ioe != null && exception.getMessage().indexOf( ioe.getMessage() ) < 0 )
|
||||
{
|
||||
message.append( "\n\nCaused by I/O exception: " ).append( ioe.getMessage() );
|
||||
}
|
||||
|
||||
if ( !wagonManager.isOnline() )
|
||||
{
|
||||
|
|
|
@ -55,6 +55,22 @@ public class MojoExecutionExceptionDiagnoser
|
|||
{
|
||||
message.append( "\n\n" ).append( longMessage );
|
||||
}
|
||||
|
||||
Throwable directCause = mee.getCause();
|
||||
|
||||
if ( directCause != null )
|
||||
{
|
||||
message.append( "\n" );
|
||||
|
||||
String directCauseMessage = directCause.getMessage();
|
||||
|
||||
if ( directCauseMessage != null && mee.getMessage().indexOf( directCauseMessage ) < 0 )
|
||||
{
|
||||
message.append( "\nEmbedded error: " ).append( directCauseMessage );
|
||||
}
|
||||
|
||||
DiagnosisUtils.appendRootCauseIfPresentAndUnique( directCause, message, false );
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
|
|
@ -77,4 +77,24 @@ public final class DiagnosisUtils
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void appendRootCauseIfPresentAndUnique( Throwable error, StringBuffer message, boolean includeTypeInfo )
|
||||
{
|
||||
Throwable root = DiagnosisUtils.getRootCause( error );
|
||||
|
||||
if ( root != null && root != error )
|
||||
{
|
||||
String rootMsg = root.getMessage();
|
||||
|
||||
if ( rootMsg != null && error.getMessage().indexOf(rootMsg) < 0 )
|
||||
{
|
||||
message.append( "\nRoot message: " ).append( rootMsg );
|
||||
|
||||
if ( includeTypeInfo )
|
||||
{
|
||||
message.append( "\nRoot error type: " ).append( root.getClass().getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,6 +128,10 @@ public class ErrorDiagnostics
|
|||
StringBuffer message = new StringBuffer();
|
||||
|
||||
message.append( error.getMessage() );
|
||||
|
||||
message.append( "\nError type: " ).append( error.getClass().getName() );
|
||||
|
||||
DiagnosisUtils.appendRootCauseIfPresentAndUnique( error, message, true );
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue