diff --git a/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java new file mode 100644 index 0000000000..6b3a2926d1 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/exception/DefaultExceptionHandler.java @@ -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) +- 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 ); + } +} diff --git a/maven-core/src/main/java/org/apache/maven/exception/ExceptionHandler.java b/maven-core/src/main/java/org/apache/maven/exception/ExceptionHandler.java new file mode 100644 index 0000000000..27e399b3e0 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/exception/ExceptionHandler.java @@ -0,0 +1,6 @@ +package org.apache.maven.exception; + +public interface ExceptionHandler +{ + ExceptionSummary handleException( Exception e ); +} diff --git a/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java b/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java new file mode 100644 index 0000000000..5f0c662520 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java @@ -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; + } +}