Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-02-19 09:49:24 -0500
committerUwe Stieber2014-02-19 09:50:02 -0500
commit6c765a492870682645600839c71d8c81b956a868 (patch)
tree13a7e7eec3c646c496c667ed7191a83697c2f792
parent48e18a1150a052f940391869a22203114da73c5c (diff)
downloadorg.eclipse.tcf-6c765a492870682645600839c71d8c81b956a868.tar.gz
org.eclipse.tcf-6c765a492870682645600839c71d8c81b956a868.tar.xz
org.eclipse.tcf-6c765a492870682645600839c71d8c81b956a868.zip
Target Explorer: Wrap value-add related IOException into specific exception wrapper
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/AbstractExternalValueAdd.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddException.java67
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddLauncher.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java8
4 files changed, 94 insertions, 19 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/AbstractExternalValueAdd.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/AbstractExternalValueAdd.java
index 45b5a963c..a45efe46b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/AbstractExternalValueAdd.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/AbstractExternalValueAdd.java
@@ -201,7 +201,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
Assert.isNotNull(id);
Assert.isNotNull(done);
- Throwable error = null;
+ ValueAddException error = null;
// Get the location of the executable image
IPath path = getLocation();
@@ -209,7 +209,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
ValueAddLauncher launcher = createLauncher(id, path);
try {
launcher.launch();
- } catch (Throwable e) {
+ } catch (ValueAddException e) {
error = e;
}
@@ -263,7 +263,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
}
if (output == null && error == null) {
String stderr = !"".equals(launcher.getErrorReader().getOutput()) ? NLS.bind(Messages.AbstractExternalValueAdd_error_output, getLabel(), formatErrorOutput(launcher.getErrorReader().getOutput())) : ""; //$NON-NLS-1$ //$NON-NLS-2$
- error = new IOException(NLS.bind(Messages.AbstractExternalValueAdd_error_failedToReadOutput, getLabel(), stderr));
+ error = new ValueAddException(new IOException(NLS.bind(Messages.AbstractExternalValueAdd_error_failedToReadOutput, getLabel(), stderr)));
}
}
@@ -298,7 +298,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
object = JSON.parseOne(output.getBytes("UTF-8")); //$NON-NLS-1$
attrs = new HashMap<String, String>((Map<String, String>)object);
} catch (IOException e) {
- error = e;
+ error = new ValueAddException(e);
}
}
@@ -317,7 +317,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
entry.peer = new Peer(attrs);
} else {
- error = new IOException(NLS.bind(Messages.AbstractExternalValueAdd_error_invalidPeerAttributes, getLabel()));
+ error = new ValueAddException(new IOException(NLS.bind(Messages.AbstractExternalValueAdd_error_invalidPeerAttributes, getLabel())));
}
}
@@ -340,7 +340,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
// On error, dispose the entry
if (error != null) entry.dispose();
} else {
- error = new FileNotFoundException(NLS.bind(Messages.AbstractExternalValueAdd_error_invalidLocation, getLabel(), (path != null ? path.toOSString() : "n/a"))); //$NON-NLS-1$
+ error = new ValueAddException(new FileNotFoundException(NLS.bind(Messages.AbstractExternalValueAdd_error_invalidLocation, getLabel(), (path != null ? path.toOSString() : "n/a")))); //$NON-NLS-1$
}
IStatus status = Status.OK_STATUS;
@@ -366,7 +366,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
*
* @return The error to report.
*/
- protected Throwable onProcessDied(ValueAddLauncher launcher, int exitCode) {
+ protected ValueAddException onProcessDied(ValueAddLauncher launcher, int exitCode) {
Assert.isNotNull(launcher);
// Read the error output if there is any
@@ -374,7 +374,7 @@ public abstract class AbstractExternalValueAdd extends AbstractValueAdd {
String cause = output != null && !"".equals(output) ? NLS.bind(Messages.AbstractExternalValueAdd_error_cause, formatErrorOutput(output)) : null; //$NON-NLS-1$
// Create the exception
String message = NLS.bind(Messages.AbstractExternalValueAdd_error_processDied, getLabel(), Integer.valueOf(exitCode));
- return new IOException(cause != null ? message + cause : message);
+ return new ValueAddException(new IOException(cause != null ? message + cause : message));
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddException.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddException.java
new file mode 100644
index 000000000..f57c95aaf
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddException.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.core.va;
+
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Value add exception implementation.
+ */
+public final class ValueAddException extends Throwable {
+ private static final long serialVersionUID = -6926835359784354123L;
+ private final Exception error;
+
+ /**
+ * Constructor.
+ *
+ * @param error The error. Must not be <code>null</code>.
+ */
+ public ValueAddException(Exception error) {
+ super();
+ Assert.isNotNull(error);
+ this.error = error;
+ }
+
+ /**
+ * Returns the error.
+ *
+ * @return The error.
+ */
+ public Exception getError() {
+ return error;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ValueAddException) {
+ return error.equals(((ValueAddException)obj).error);
+ }
+ return super.equals(obj);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return error.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#toString()
+ */
+ @Override
+ public String toString() {
+ return error.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddLauncher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddLauncher.java
index 717c747c3..f6ba3d684 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddLauncher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/va/ValueAddLauncher.java
@@ -105,7 +105,7 @@ public class ValueAddLauncher extends ProcessLauncher {
* @see org.eclipse.tcf.te.runtime.processes.ProcessLauncher#launch()
*/
@Override
- public void launch() throws Throwable {
+ public void launch() throws ValueAddException {
IPath dir = path.removeLastSegments(1);
String cmd = Host.isWindowsHost() ? path.toOSString() : "./" + path.lastSegment(); //$NON-NLS-1$
@@ -164,9 +164,9 @@ public class ValueAddLauncher extends ProcessLauncher {
* Add the value-add command line parameters to the command.
*
* @param command The command. Must not be <code>null</code>.
- * @throws Throwable In case something failed while adding the command line parameters.
+ * @throws ValueAddException In case something failed while adding the command line parameters.
*/
- protected void addCommandLineParameters(List<String> command) throws Throwable {
+ protected void addCommandLineParameters(List<String> command) throws ValueAddException {
Assert.isNotNull(command);
// Determine a free port to use by the value-add. We must
@@ -182,9 +182,9 @@ public class ValueAddLauncher extends ProcessLauncher {
* Add the value-add logging command line parameters to the command.
*
* @param command The command. Must not be <code>null</code>.
- * @throws Throwable In case something failed while adding the logging command line parameters.
+ * @throws ValueAddException In case something failed while adding the logging command line parameters.
*/
- protected void addLoggingCommandLineParameters(List<String> command) throws Throwable {
+ protected void addLoggingCommandLineParameters(List<String> command) throws ValueAddException {
Assert.isNotNull(command);
// Enable logging?
@@ -222,9 +222,17 @@ public class ValueAddLauncher extends ProcessLauncher {
* @return The process instance.
* @see Runtime#exec(String[], String[], File)
*/
- protected Process exec(String[] cmdarray, String[] envp, File dir) throws IOException {
+ protected Process exec(String[] cmdarray, String[] envp, File dir) throws ValueAddException {
Assert.isNotNull(cmdarray);
- return Runtime.getRuntime().exec(cmdarray, envp, dir);
+
+ Process process = null;
+ try {
+ process = Runtime.getRuntime().exec(cmdarray, envp, dir);
+ } catch (IOException e) {
+ throw new ValueAddException(e);
+ }
+
+ return process;
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
index 4b2f216b7..38a3f3e64 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
@@ -10,7 +10,6 @@
package org.eclipse.tcf.te.tcf.locator.steps;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -33,6 +32,7 @@ import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.core.Tcf;
import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
import org.eclipse.tcf.te.tcf.core.interfaces.steps.ITcfStepAttributes;
+import org.eclipse.tcf.te.tcf.core.va.ValueAddException;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
import org.eclipse.tcf.te.tcf.locator.nls.Messages;
@@ -117,9 +117,9 @@ public class WaitForReadyStep extends AbstractPeerNodeStep {
return;
}
- // License errors are reported to the user and breaks the wait immediately
- if (error instanceof IOException) {
- callback(data, fullQualifiedId, callback, StatusHelper.getStatus(error), null);
+ // Value add exceptions are reported to the user and breaks the wait immediately
+ if (error instanceof ValueAddException) {
+ callback(data, fullQualifiedId, callback, StatusHelper.getStatus(((ValueAddException) error).getError()), null);
return;
}

Back to the top