From 06dc81b54e48b76ce25675f2ae52e39ac8aeb396 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Wed, 12 Oct 2005 05:05:39 +0000 Subject: [PATCH] Cleaning up diagnosis output for MojoExecutionException's. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@314785 13f79535-47bb-0310-9956-ffa450edef68 --- .../MojoExecutionExceptionDiagnoser.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) 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 986d377c27..23e2b8b267 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 @@ -17,16 +17,35 @@ public class MojoExecutionExceptionDiagnoser StringBuffer message = new StringBuffer(); - message.append( "Error executing mojo: " ).append( mee.getSource() ).append( "\n\n" ); - message.append( mee.getLongMessage() ).append( "\n\n" ); + message.append( "Error executing mojo" ); + + Object source = mee.getSource(); + if ( source != null ) + { + message.append( ": " ).append( mee.getSource() ).append( "\n" ); + } + else + { + message.append( ".\n" ); + } + + message.append( "\nMessage: " ).append( mee.getMessage() ); + + String longMessage = mee.getLongMessage(); + if ( longMessage != null ) + { + message.append( "\n\n" ).append( longMessage ); + } Throwable root = DiagnosisUtils.getRootCause( mee ); if ( root != null && root != mee ) { - message.append( "Root Cause: " ).append( root.getMessage() ).append( "\n\n" ); + message.append( "\n\nRoot Cause: " ).append( root.getMessage() ); } + message.append( "\n\n" ); + return message.toString(); }