o Tweaked error message formatting

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@829065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-10-23 13:55:01 +00:00
parent a05c12af81
commit f5a93816c7
1 changed files with 37 additions and 21 deletions

View File

@ -203,11 +203,6 @@ public class DefaultExceptionHandler
{
String exceptionMessage = t.getMessage();
if ( exceptionMessage == null )
{
exceptionMessage = "";
}
if ( t instanceof AbstractMojoExecutionException )
{
String longMessage = ( (AbstractMojoExecutionException) t ).getLongMessage();
@ -219,35 +214,56 @@ public class DefaultExceptionHandler
}
else
{
exceptionMessage += ": " + longMessage;
exceptionMessage = join( exceptionMessage, longMessage );
}
}
}
if ( StringUtils.isEmpty( exceptionMessage ) )
{
exceptionMessage = t.getClass().getSimpleName();
}
if ( t instanceof UnknownHostException && !fullMessage.contains( "host" ) )
{
if ( fullMessage.length() > 0 )
{
fullMessage += ": ";
}
fullMessage += "Unknown host " + exceptionMessage;
fullMessage = join( fullMessage, "Unknown host " + exceptionMessage );
}
else if ( !fullMessage.contains( exceptionMessage ) )
{
if ( fullMessage.length() > 0 )
{
fullMessage += ": ";
}
fullMessage += exceptionMessage;
fullMessage = join( fullMessage, exceptionMessage );
}
}
if ( StringUtils.isEmpty( fullMessage ) && exception != null )
{
fullMessage = exception.toString();
}
return fullMessage.trim();
}
private String join( String message1, String message2 )
{
String message = "";
if ( StringUtils.isNotEmpty( message1 ) )
{
message = message1.trim();
}
if ( StringUtils.isNotEmpty( message2 ) )
{
if ( StringUtils.isNotEmpty( message ) )
{
if ( message.endsWith( "." ) || message.endsWith( "!" ) || message.endsWith( ":" ) )
{
message += " ";
}
else
{
message += ": ";
}
}
message += message2;
}
return message;
}
}