Skip to content

Commit

Permalink
Update DispatcherException and display of workflow result errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Apr 6, 2011
1 parent f68c98b commit 6e9c689
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,55 @@
*/
package com.dtolabs.rundeck.core.execution.dispatch;

import com.dtolabs.rundeck.core.common.INodeEntry;

/**
* DispatcherException is ...
*
* @author Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
*/
public class DispatcherException extends Exception {
private INodeEntry node;

public DispatcherException() {
super();
}

public DispatcherException(String msg) {
super(msg);
public DispatcherException(String s) {
super(s);
}

public DispatcherException(String s, Throwable throwable) {
super(s, throwable);
}

public DispatcherException(Throwable throwable) {
super(throwable);
}

public DispatcherException(INodeEntry node) {
this.node = node;
}

public DispatcherException(String s, INodeEntry node) {
super(s);
this.node = node;
}

public DispatcherException(String s, Throwable throwable, INodeEntry node) {
super(s, throwable);
this.node = node;
}

public DispatcherException(Throwable throwable, INodeEntry node) {
super(throwable);
this.node = node;
}

public DispatcherException(Throwable cause) {
super(cause);
public INodeEntry getNode() {
return node;
}

public DispatcherException(String msg, Throwable cause) {
super(msg, cause);
public void setNode(INodeEntry node) {
this.node = node;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public DispatcherResult dispatch(final ExecutionContext context,
failedListener.nodesFailed(failures);
}
throw new DispatcherException(
"Failed dispatching to node " + node.getNodename() + ": " + e.getMessage(), e);
"Failed dispatching to node " + node.getNodename() + ": " + e.getMessage(), e, node);
} else {
context.getExecutionListener().log(Constants.ERR_LEVEL,
"Failed dispatching to node " + node.getNodename() + ": " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import com.dtolabs.rundeck.core.Constants;
import com.dtolabs.rundeck.core.common.Framework;
import com.dtolabs.rundeck.core.common.INodeEntry;
import com.dtolabs.rundeck.core.execution.*;
import com.dtolabs.rundeck.core.execution.dispatch.DispatcherException;
import com.dtolabs.rundeck.core.execution.dispatch.DispatcherResult;

import java.util.*;
Expand Down Expand Up @@ -77,8 +79,12 @@ public Exception getException() {

@Override
public String toString() {
return "Workflow, result: " + getResultSet() + ", failures: " + getFailureMessages() + (
null != getException() ? ": exception: " + getException() : "");
return "[Workflow result: "
+ (null != getResultSet() && getResultSet().size() > 0 ? "result: " + getResultSet() : "")
+ (null != getFailureMessages() && getFailureMessages().size() > 0 ? ", failures: "
+ getFailureMessages() : "")
+ (null != getException() ? ": exception: " + getException() : "")
+ "]";
}

}
Expand Down Expand Up @@ -262,6 +268,14 @@ protected Map<String, Collection<String>> convertFailures(Map<Integer, Object> f
}
failures.get(s).add(interpreterResult.toString());
}
} else if (o instanceof DispatcherException) {
DispatcherException e = (DispatcherException) o;
final INodeEntry node = e.getNode();
final String key = null != node ? node.getNodename() : "?";
if (!failures.containsKey(key)) {
failures.put(key, new ArrayList<String>());
}
failures.get(key).add(e.getMessage());
} else if (o instanceof Exception) {
Exception e = (Exception) o;
if (!failures.containsKey("?")) {
Expand Down

0 comments on commit 6e9c689

Please sign in to comment.