allow both error and failure exceptions from mojos instead of just checking for a null cause

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@291632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-26 14:40:17 +00:00
parent 69fc4d27ea
commit ed370a6382
4 changed files with 100 additions and 15 deletions

View File

@ -232,8 +232,15 @@ public class DefaultMaven
writeReactorSummary( rm );
}
}
else if ( exception instanceof MojoFailureException )
{
MojoFailureException e = (MojoFailureException) exception;
logFailure( response, e, e.getLongMessage() );
}
else if ( exception instanceof MojoExecutionException )
{
// TODO: replace by above
if ( exception.getCause() == null )
{
MojoExecutionException e = (MojoExecutionException) exception;

View File

@ -0,0 +1,51 @@
package org.apache.maven.plugin;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Base exception.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public abstract class AbstractMojoExecutionException
extends Exception
{
protected Object source;
protected String longMessage;
public AbstractMojoExecutionException( String message )
{
super( message );
}
public AbstractMojoExecutionException( String message, Throwable cause )
{
super( message, cause );
}
public String getLongMessage()
{
return longMessage;
}
public Object getSource()
{
return source;
}
}

View File

@ -17,18 +17,14 @@ package org.apache.maven.plugin;
*/
/**
* A failure or exception occuring during the execution of a plugin.
* An exception occuring during the execution of a plugin.
*
* @author Brett Porter
* @version $Id$
*/
public class MojoExecutionException
extends Exception
extends AbstractMojoExecutionException
{
private Object source;
private String longMessage;
public MojoExecutionException( Object source, String shortMessage, String longMessage )
{
super( shortMessage );
@ -51,13 +47,4 @@ public class MojoExecutionException
super( message );
}
public String getLongMessage()
{
return longMessage;
}
public Object getSource()
{
return source;
}
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.plugin;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* An exception occuring during the execution of a plugin.
*
* @author Brett Porter
* @version $Id$
*/
public class MojoFailureException
extends AbstractMojoExecutionException
{
public MojoFailureException( Object source, String shortMessage, String longMessage )
{
super( shortMessage );
this.source = source;
this.longMessage = longMessage;
}
public MojoFailureException( String message )
{
super( message );
}
}