diff --git a/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java index 6c5bfec95d..2668dbb480 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java @@ -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() ) { diff --git a/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java b/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java index 0e7d3a4ff7..9b87102a46 100644 --- a/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java +++ b/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.java @@ -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(); } diff --git a/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/DiagnosisUtils.java b/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/DiagnosisUtils.java index 746f6eeb79..636f0206d9 100644 --- a/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/DiagnosisUtils.java +++ b/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/DiagnosisUtils.java @@ -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() ); + } + } + } + } } diff --git a/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java b/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java index f1ca3c29e3..21516c4b5a 100644 --- a/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java +++ b/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.java @@ -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(); }