Skip to content

Commit

Permalink
capture R exceptions and display them (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Graff authored Dec 11, 2017
1 parent 9ef083f commit 130012e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ synchronized public MannWhitneyResult eval(MannWhitneyParams params) throws RExe
re.assign("controlData", params.getControlData());
re.assign("experimentData", params.getExperimentData());
String command = params.toCommandString("controlData", "experimentData");
REXP result = re.eval(command);
REXP result = re.parseAndEval("try(eval(" + command + "),silent=TRUE)");
if (result == null) {
throw new RExecutionException("Failed to get a result from R for Mann-Whitney test");
throw new RExecutionException("Failed to get a result from R for Mann-Whitney test. command:" + command);
}
if (result.inherits("try-error")) {
throw new RExecutionException("Failed to get a result from R for Mann-Whitney test. command: " + command + ", error: " + result.asString());
}

RList list = result.asList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ public class MannWhitneyParams {
@Getter
private double[] experimentData;

String toCommandString() {
StringBuilder ret = new StringBuilder();
ret.append("wilcox.test(");
appendVector(ret, controlData);
ret.append(",");
appendVector(ret, experimentData);
ret.append(",conf.int=TRUE,mu=");
ret.append(mu);
ret.append(",conf.level=");
ret.append(confidenceLevel);
ret.append(")");
return ret.toString();
}

String toCommandString(String controlName, String experimentName) {
String ret = "wilcox.test(" + experimentName + "," + controlName;
ret += ",conf.int=TRUE,mu=" + mu;
Expand Down

0 comments on commit 130012e

Please sign in to comment.