mirror of https://github.com/apache/maven.git
o adding exception handling code
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@769609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d78af4efbe
commit
e59d107cf1
|
@ -0,0 +1,73 @@
|
|||
package org.apache.maven.exception;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
|
||||
/*
|
||||
|
||||
All Possible Errors
|
||||
- bad command line parameter
|
||||
- malformed settings
|
||||
- malformed POM
|
||||
- local repository not writable
|
||||
- remote repositories not available
|
||||
- artifact metadata missing
|
||||
- extension metadata missing
|
||||
- extension artifact missing
|
||||
- artifact metadata retrieval problem
|
||||
- version range violation
|
||||
- circular dependency
|
||||
- artifact missing
|
||||
- artifact retrieval exception
|
||||
- plugin metadata missing
|
||||
- plugin metadata retrieval problem
|
||||
- plugin artifact missing
|
||||
- plugin artifact retrieval problem
|
||||
- plugin dependency metadata missing
|
||||
- plugin dependency metadata retrieval problem
|
||||
- plugin configuration problem
|
||||
- plugin execution failure due to something that is know to possibly go wrong (like compilation failure)
|
||||
- plugin execution error due to something that is not expected to go wrong (the compiler executable missing)
|
||||
- md5 checksum doesn't match for local artifact, need to redownload this
|
||||
|
||||
brett:
|
||||
- transitive dependency problems - tracking down
|
||||
- invalid lifecycle phase (maybe same as bad CLI param, though you were talking about embedder too)
|
||||
- <module> specified is not found
|
||||
- POM doesn't exist for a goal that requires one
|
||||
- goal not found in a plugin (probably could list the ones that are)
|
||||
- parent POM missing (in both the repository + relative path)
|
||||
brian:
|
||||
- component not found
|
||||
- missing goal in plugin
|
||||
- removing the scripting options from the core
|
||||
|
||||
*/
|
||||
|
||||
@Component(role=ExceptionHandler.class)
|
||||
public class DefaultExceptionHandler
|
||||
implements ExceptionHandler
|
||||
{
|
||||
public ExceptionSummary handleException( Exception exception )
|
||||
{
|
||||
String message;
|
||||
|
||||
String reference = "http://";
|
||||
|
||||
if ( exception instanceof MojoFailureException )
|
||||
{
|
||||
message = ((MojoFailureException)exception).getLongMessage();
|
||||
}
|
||||
else if ( exception instanceof MojoExecutionException )
|
||||
{
|
||||
message = ((MojoExecutionException)exception).getLongMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
message = exception.getMessage();
|
||||
}
|
||||
|
||||
return new ExceptionSummary( exception, message, reference );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package org.apache.maven.exception;
|
||||
|
||||
public interface ExceptionHandler
|
||||
{
|
||||
ExceptionSummary handleException( Exception e );
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.apache.maven.exception;
|
||||
|
||||
// provide a
|
||||
// - the exception
|
||||
// - useful message
|
||||
// - useful reference to a solution, or set of solutions
|
||||
// - the configuration gleaned for examination
|
||||
// - plugin repositories
|
||||
|
||||
public class ExceptionSummary
|
||||
{
|
||||
private Exception exception;
|
||||
|
||||
private String message;
|
||||
|
||||
private String reference;
|
||||
|
||||
public ExceptionSummary( Exception exception, String message, String reference )
|
||||
{
|
||||
this.exception = exception;
|
||||
this.message = message;
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public Exception getException()
|
||||
{
|
||||
return exception;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getReference()
|
||||
{
|
||||
return reference;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue