o Improved error reporting

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@788375 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-06-25 15:00:20 +00:00
parent e3463be3d1
commit c8f94b4eaf
3 changed files with 33 additions and 7 deletions

View File

@ -509,8 +509,8 @@ public class DefaultPluginManager
}
catch ( ComponentLookupException e )
{
throw new PluginContainerException( mojoDescriptor, pluginRealm, "Unable to find the mojo '" + mojoDescriptor.getRoleHint() + "' in the plugin '" + pluginDescriptor.getPluginLookupKey()
+ "'", e );
throw new PluginContainerException( mojoDescriptor, pluginRealm, "Unable to find the mojo '"
+ mojoDescriptor.getGoal() + "' in the plugin '" + pluginDescriptor.getId() + "'", e );
}
if ( mojo instanceof ContextEnabled )
@ -598,6 +598,12 @@ public class DefaultPluginManager
{
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "Unable to retrieve component configurator for plugin configuration", e );
}
catch ( NoClassDefFoundError e )
{
throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
"A required class was missing during mojo configuration: "
+ e.getMessage(), e );
}
catch ( LinkageError e )
{
if ( logger.isFatalErrorEnabled() )

View File

@ -42,23 +42,30 @@ public class PluginConfigurationException
this.originalMessage = originalMessage;
}
public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, Throwable cause )
{
super( originalMessage, cause );
this.pluginDescriptor = pluginDescriptor;
this.originalMessage = originalMessage;
}
public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, ExpressionEvaluationException cause )
{
super( cause );
super( originalMessage, cause );
this.pluginDescriptor = pluginDescriptor;
this.originalMessage = originalMessage;
}
public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, ComponentConfigurationException cause )
{
super( cause );
super( originalMessage, cause );
this.pluginDescriptor = pluginDescriptor;
this.originalMessage = originalMessage;
}
public PluginConfigurationException( PluginDescriptor pluginDescriptor, String originalMessage, ComponentLookupException cause )
{
super( cause );
super( originalMessage, cause );
this.pluginDescriptor = pluginDescriptor;
this.originalMessage = originalMessage;
}

View File

@ -17,13 +17,13 @@ public class PluginExecutionException
public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, Exception cause )
{
super( mojoExecution.getMojoDescriptor(), project, "Mojo execution failed.", cause );
super( mojoExecution.getMojoDescriptor(), project, constructMessage( cause ), cause );
this.mojoExecution = mojoExecution;
}
public PluginExecutionException( MojoExecution mojoExecution, MavenProject project, DuplicateArtifactAttachmentException cause )
{
super( mojoExecution.getMojoDescriptor(), project, "Mojo execution failed.", cause );
super( mojoExecution.getMojoDescriptor(), project, constructMessage( cause ), cause );
this.mojoExecution = mojoExecution;
}
@ -31,4 +31,17 @@ public class PluginExecutionException
{
return mojoExecution;
}
private static String constructMessage( Throwable cause )
{
if ( cause != null )
{
return "Mojo execution failed: " + cause.getMessage();
}
else
{
return "Mojo execution failed.";
}
}
}