Bug 500344 - Always wrap cause if throwing new exception
Change-Id: I1a936ce009b8dd824c5fa11b0f2d6d27a0f43d06
Signed-off-by: Andreas Sewe <andreas.sewe@codetrails.com>
diff --git a/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/contentDescriber/AntBuildfileContentDescriber.java b/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/contentDescriber/AntBuildfileContentDescriber.java
index 1c49243..a99b0d9 100644
--- a/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/contentDescriber/AntBuildfileContentDescriber.java
+++ b/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/contentDescriber/AntBuildfileContentDescriber.java
@@ -60,7 +60,7 @@
catch (ParserConfigurationException e) {
// some bad thing happened - force this describer to be disabled
String message = "Internal Error: XML parser configuration error during content description for Ant buildfiles"; //$NON-NLS-1$
- throw new RuntimeException(message);
+ throw new RuntimeException(message, e);
}
// Check to see if we matched our criteria.
if (antHandler.hasRootProjectElement()) {
diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
index db61352..d517ec8 100644
--- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
+++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
@@ -237,7 +237,8 @@
}
}
catch (ClassCastException e) {
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildListener, new Object[] { className });
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildListener, new Object[] {
+ className });
if (log) {
logMessage(null, message, Project.MSG_ERR);
}
@@ -323,7 +324,8 @@
project.checkTaskClass(taskClass);
}
catch (BuildException e) {
- IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Error_setting_Ant_task, new Object[] { task.getTaskName() }), e);
+ IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Error_setting_Ant_task, new Object[] {
+ task.getTaskName() }), e);
AntCorePlugin.getPlugin().getLog().log(status);
continue;
}
@@ -373,10 +375,12 @@
protected void parseBuildFile(Project project) {
File buildFile = new File(getBuildFileLocation());
if (!buildFile.exists()) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_does_not_exist, new Object[] { buildFile.getAbsolutePath() }));
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_does_not_exist, new Object[] {
+ buildFile.getAbsolutePath() }));
}
if (!buildFile.isFile()) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_is_not_a_file, new Object[] { buildFile.getAbsolutePath() }));
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_is_not_a_file, new Object[] {
+ buildFile.getAbsolutePath() }));
}
if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
@@ -448,8 +452,8 @@
}
if (!defaultFound) {
// default target must exist
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Default_target_does_not_exist, new Object[] {
- "'", defaultTarget, "'" })); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Default_target_does_not_exist, new Object[] { "'", //$NON-NLS-1$
+ defaultTarget, "'" })); //$NON-NLS-1$
}
return infos;
}
@@ -569,7 +573,8 @@
}
/**
- * Attempts to run the given list of command line arguments. Note that the list passed to this method must support {@link List#remove(Object)}. <br>
+ * Attempts to run the given list of command line arguments. Note that the list passed to this method must support {@link List#remove(Object)}.
+ * <br>
* <br>
* This method directly processes the following arguments:
* <ul>
@@ -664,7 +669,8 @@
}
if (!projectHelp) {
- logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Build_file, new Object[] { getBuildFileLocation() }), Project.MSG_INFO);
+ logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Build_file, new Object[] {
+ getBuildFileLocation() }), Project.MSG_INFO);
setTasks(getCurrentProject());
setTypes(getCurrentProject());
@@ -794,12 +800,14 @@
buildLogger = (BuildLogger) (Class.forName(loggerClassname).newInstance());
}
catch (ClassCastException e) {
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildLogger, new Object[] { loggerClassname });
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildLogger, new Object[] {
+ loggerClassname });
logMessage(null, message, Project.MSG_ERR);
throw new BuildException(message, e);
}
catch (Exception e) {
- String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_Unable_to_instantiate_logger, new Object[] { loggerClassname });
+ String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_Unable_to_instantiate_logger, new Object[] {
+ loggerClassname });
logMessage(null, message, Project.MSG_ERR);
throw new BuildException(message, e);
}
@@ -992,10 +1000,12 @@
antVersionNumber = versionNumber;
}
catch (IOException ioe) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[] { ioe.getMessage() }));
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[] {
+ ioe.getMessage() }), ioe);
}
catch (NullPointerException npe) {
- throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[] { npe.getMessage() }));
+ throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, new Object[] {
+ npe.getMessage() }), npe);
}
}
return antVersionNumber;
@@ -1162,7 +1172,8 @@
}
catch (IOException e) {
// just log message and ignore exception
- logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_write_to_log_file, new Object[] { arg }), Project.MSG_ERR);
+ logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_write_to_log_file, new Object[] {
+ arg }), Project.MSG_ERR);
return false;
}
@@ -1297,7 +1308,8 @@
// this stream is closed in the finally block of run(list)
out = new PrintStream(new FileOutputStream(logFile));
err = out;
- logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Using_file_as_build_log, new Object[] { logFile.getCanonicalPath() }), Project.MSG_INFO);
+ logMessage(currentProject, MessageFormat.format(InternalAntMessages.InternalAntRunner_Using_file_as_build_log, new Object[] {
+ logFile.getCanonicalPath() }), Project.MSG_INFO);
if (buildLogger != null) {
buildLogger.setErrorPrintStream(err);
buildLogger.setOutputPrintStream(out);
@@ -1435,7 +1447,8 @@
}
}
catch (IOException e) {
- fEarlyErrorMessage = MessageFormat.format(InternalAntMessages.InternalAntRunner_could_not_load_property_file, new Object[] { e.getMessage() });
+ fEarlyErrorMessage = MessageFormat.format(InternalAntMessages.InternalAntRunner_could_not_load_property_file, new Object[] {
+ e.getMessage() });
}
}
diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java
index e6961a1..72a59cf 100644
--- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java
+++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java
@@ -179,7 +179,8 @@
}
}
catch (ClassCastException e) {
- String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_be_a_build_listener_is_not_an_instance_of_org.apache.tools.ant.BuildListener._1"), new Object[] { clazz }); //$NON-NLS-1$
+ String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_be_a_build_listener_is_not_an_instance_of_org.apache.tools.ant.BuildListener._1"), new Object[] { //$NON-NLS-1$
+ clazz });
logMessage(null, message, Project.MSG_ERR);
throw new BuildException(message, e);
}
@@ -418,7 +419,8 @@
}
}
- getCurrentProject().log(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Build_file__{0}_1"), new Object[] { getBuildFileLocation() })); //$NON-NLS-1$
+ getCurrentProject().log(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Build_file__{0}_1"), new Object[] { //$NON-NLS-1$
+ getBuildFileLocation() }));
setTasks();
setTypes();
@@ -502,7 +504,8 @@
getCurrentProject().addTaskDefinition(taskName, taskClass);
}
catch (ClassNotFoundException e) {
- String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.161"), new Object[] { taskClassName, taskName }); //$NON-NLS-1$
+ String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.161"), new Object[] { taskClassName, //$NON-NLS-1$
+ taskName });
getCurrentProject().log(message, Project.MSG_WARN);
}
}
@@ -529,7 +532,8 @@
getCurrentProject().addDataTypeDefinition(typeName, typeClass);
}
catch (ClassNotFoundException e) {
- String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.162"), new Object[] { typeClassName, typeName }); //$NON-NLS-1$
+ String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.162"), new Object[] { typeClassName, //$NON-NLS-1$
+ typeName });
getCurrentProject().log(message, Project.MSG_WARN);
}
}
@@ -558,12 +562,14 @@
buildLogger = (BuildLogger) (Class.forName(loggerClassname).newInstance());
}
catch (ClassCastException e) {
- String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_perform_logging_is_not_an_instance_of_org.apache.tools.ant.BuildLogger._2"), new Object[] { loggerClassname }); //$NON-NLS-1$
+ String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_perform_logging_is_not_an_instance_of_org.apache.tools.ant.BuildLogger._2"), new Object[] { //$NON-NLS-1$
+ loggerClassname });
logMessage(null, message, Project.MSG_ERR);
throw new BuildException(message, e);
}
catch (Exception e) {
- String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_logger__{0}_6"), new Object[] { loggerClassname }); //$NON-NLS-1$
+ String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_logger__{0}_6"), new Object[] { //$NON-NLS-1$
+ loggerClassname });
logMessage(null, message, Project.MSG_ERR);
throw new BuildException(message, e);
}
@@ -665,10 +671,11 @@
antVersionNumber = versionNumber;
}
catch (IOException ioe) {
- throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._{0}_9"), new Object[] { ioe.getMessage() })); //$NON-NLS-1$
+ throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._{0}_9"), new Object[] { //$NON-NLS-1$
+ ioe.getMessage() }), ioe);
}
catch (NullPointerException npe) {
- throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._10")); //$NON-NLS-1$
+ throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._10"), npe); //$NON-NLS-1$
}
}
return antVersionNumber;
@@ -785,7 +792,8 @@
}
catch (IOException e) {
// just log message and ignore exception
- logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_write_to_the_specified_log_file__{0}._Make_sure_the_path_exists_and_you_have_write_permissions._2"), new Object[] { arg }), Project.MSG_ERR); //$NON-NLS-1$
+ logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_write_to_the_specified_log_file__{0}._Make_sure_the_path_exists_and_you_have_write_permissions._2"), new Object[] { //$NON-NLS-1$
+ arg }), Project.MSG_ERR);
return false;
}
@@ -901,7 +909,8 @@
}
// warn of ignored commands
- String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unknown_argument__{0}_2"), new Object[] { s.substring(1) }); //$NON-NLS-1$
+ String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unknown_argument__{0}_2"), new Object[] { //$NON-NLS-1$
+ s.substring(1) });
logMessage(currentProject, message, Project.MSG_WARN);
}
@@ -927,7 +936,8 @@
// this stream is closed in the finally block of run(list)
out = new PrintStream(new FileOutputStream(logFile));
err = out;
- logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Using_{0}_file_as_build_log._1"), new Object[] { logFile.getCanonicalPath() }), Project.MSG_INFO); //$NON-NLS-1$
+ logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Using_{0}_file_as_build_log._1"), new Object[] { //$NON-NLS-1$
+ logFile.getCanonicalPath() }), Project.MSG_INFO);
if (buildLogger != null) {
buildLogger.setErrorPrintStream(err);
buildLogger.setOutputPrintStream(out);
@@ -1150,7 +1160,7 @@
}
String command = commands.get(index);
- if (command.startsWith("-")) { //new parameter //$NON-NLS-1$
+ if (command.startsWith("-")) { // new parameter //$NON-NLS-1$
return IAntCoreConstants.EMPTY_STRING;
}
@@ -1177,7 +1187,8 @@
props.load(fis);
}
catch (IOException e) {
- fEarlyErrorMessage = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_property_file_{0}__{1}_4"), new Object[] { filename, e.getMessage() }); //$NON-NLS-1$
+ fEarlyErrorMessage = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_property_file_{0}__{1}_4"), new Object[] { //$NON-NLS-1$
+ filename, e.getMessage() });
}
if (userProperties == null) {
userProperties = new HashMap<>();
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/ParseError.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/ParseError.java
index a01fda1..778c7a7 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/ParseError.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/ParseError.java
@@ -27,4 +27,16 @@
public ParseError(String msg) {
super(msg);
}
+
+ /**
+ * Constructor for ParseError.
+ *
+ * @param msg
+ * Message
+ * @param cause
+ * Cause
+ */
+ public ParseError(String msg, Throwable cause) {
+ super(msg, cause);
+ }
}
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java
index def6988..e34a823 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java
@@ -77,10 +77,10 @@
parser.parse(inputSource);
}
catch (SAXNotRecognizedException e) {
- throw new ParseError(NOT_SUPPORTED);
+ throw new ParseError(NOT_SUPPORTED, e);
}
catch (SAXNotSupportedException e) {
- throw new ParseError(NOT_SUPPORTED);
+ throw new ParseError(NOT_SUPPORTED, e);
}
catch (SAXException e) {
// Don't care about errors in XML, so just fall thru.
@@ -99,10 +99,10 @@
return parser.getXMLReader();
}
catch (ParserConfigurationException e) {
- throw new ParseError(e.getMessage());
+ throw new ParseError(e.getMessage(), e);
}
catch (SAXException e) {
- throw new ParseError(e.getMessage());
+ throw new ParseError(e.getMessage(), e);
}
}
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlFormatter.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlFormatter.java
index ecb54a3..2d2d0a0 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlFormatter.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlFormatter.java
@@ -180,7 +180,8 @@
doc.addPosition(POS_CATEGORY, positions[i]);
}
catch (BadLocationException e) {
- throw new IllegalArgumentException("Position outside of string. offset: " + positions[i].offset + ", length: " + positions[i].length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ throw new IllegalArgumentException("Position outside of string. offset: " + positions[i].offset + ", length: " //$NON-NLS-1$//$NON-NLS-2$
+ + positions[i].length + ", string size: " + string.length(), e); //$NON-NLS-1$
}
}
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java
index ce74d57..1725bbc 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java
@@ -11,7 +11,6 @@
package org.eclipse.ant.internal.ui.datatransfer;
import java.io.File;
-import com.ibm.icu.text.MessageFormat;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Javac;
@@ -36,6 +35,8 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.launching.JavaRuntime;
+import com.ibm.icu.text.MessageFormat;
+
public class ProjectCreator {
public IJavaProject createJavaProjectFromJavacNode(String projectName, Javac javacTask, IProgressMonitor monitor) throws CoreException {
@@ -79,7 +80,8 @@
}
}
catch (BuildException be) {
- IStatus status = new Status(IStatus.ERROR, AntUIPlugin.PI_ANTUI, IStatus.OK, MessageFormat.format(DataTransferMessages.ProjectCreator_0, new Object[] { be.getLocalizedMessage() }), null);
+ IStatus status = new Status(IStatus.ERROR, AntUIPlugin.PI_ANTUI, IStatus.OK, MessageFormat.format(DataTransferMessages.ProjectCreator_0, new Object[] {
+ be.getLocalizedMessage() }), be);
throw new CoreException(status);
}
}