PR: MNG-344

correctly render exceptions for initial project retrieval failure

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@169591 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-05-11 05:58:03 +00:00
parent 8fc3e7a305
commit c334dfaf2a
4 changed files with 44 additions and 24 deletions

View File

@ -80,28 +80,26 @@ public class ArtifactResolutionException
}
}
// TODO: don't show this section for metadata
sb.append( LS );
sb.append( LS );
sb.append( "Try downloading the file manually" );
if ( downloadUrl != null )
if ( downloadUrl != null && !type.equals( "pom" ) )
{
sb.append( " from " );
sb.append( LS );
sb.append( LS );
sb.append( "Try downloading the file manually from" );
sb.append( LS );
sb.append( " " + downloadUrl );
sb.append( LS );
sb.append( "and install it using the command: " );
sb.append( LS );
sb.append( " m2 install:install-file -DgroupId=" );
sb.append( groupId );
sb.append( " -DartifactId=" );
sb.append( artifactId );
sb.append( " -Dversion=" );
sb.append( version );
sb.append( " -Dpackaging=" );
sb.append( type );
sb.append( " -Dfile=/path/to/file" );
}
sb.append( LS );
sb.append( "and install it using the command: " );
sb.append( LS );
sb.append( " m2 install:install-file -DgroupId=" );
sb.append( groupId );
sb.append( " -DartifactId=" );
sb.append( artifactId );
sb.append( " -Dversion=" );
sb.append( version );
sb.append( " -Dpackaging=" );
sb.append( type );
sb.append( " -Dfile=/path/to/file" );
return sb.toString();
}

View File

@ -58,6 +58,7 @@ import java.util.Map;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id$
* @todo unify error reporting. We should return one response, always - and let the CLI decide how to render it. The reactor response should contain individual project responses
*/
public class DefaultMaven
extends AbstractLogEnabled
@ -120,17 +121,33 @@ public class DefaultMaven
{
throw new ReactorException( "Error processing projects for the reactor: ", e );
}
catch ( ProjectBuildingException e )
{
throw new ReactorException( "Error processing projects for the reactor: ", e );
}
catch ( CycleDetectedException e )
{
throw new ReactorException( "Error processing projects for the reactor: ", e );
}
catch ( ArtifactResolutionException e )
{
throw new ReactorException( "Error processing projects for the reactor: ", e );
dispatcher.dispatchError( event, request.getBaseDirectory(), e );
MavenExecutionResponse response = new MavenExecutionResponse();
response.setStart( new Date() );
response.setFinish( new Date() );
response.setException( e );
logFailure( response, e, null );
return response;
}
catch ( ProjectBuildingException e )
{
dispatcher.dispatchError( event, request.getBaseDirectory(), e );
MavenExecutionResponse response = new MavenExecutionResponse();
response.setStart( new Date() );
response.setFinish( new Date() );
response.setException( e );
logFailure( response, e, null );
return response;
}
try
@ -150,6 +167,8 @@ public class DefaultMaven
MavenExecutionResponse response = processProject( request, project, dispatcher );
if ( response.isExecutionFailure() )
{
dispatcher.dispatchError( event, request.getBaseDirectory(), response.getException() );
return response;
}
}
@ -414,6 +433,7 @@ public class DefaultMaven
line();
}
// TODO: needs to honour -e
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Trace", e );

View File

@ -19,6 +19,8 @@ package org.apache.maven;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResponse;
import org.apache.maven.reactor.ReactorException;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>

View File

@ -272,7 +272,7 @@ public class MavenCli
}
else
{
System.err.println( "For more information, run with the -X flag" );
System.err.println( "For more information, run with the -e flag" );
}
}