Skip to content

Commit cd77cac

Browse files
committed
Better error message for when genemania query times out.
1 parent 5e24057 commit cd77cac

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/task/genemania/QueryGeneManiaTask.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.cytoscape.work.FinishStatus;
1313
import org.cytoscape.work.ObservableTask;
1414
import org.cytoscape.work.ProvidesTitle;
15+
import org.cytoscape.work.SynchronousTaskManager;
1516
import org.cytoscape.work.TaskIterator;
1617
import org.cytoscape.work.TaskMonitor;
1718
import org.cytoscape.work.TaskObserver;
@@ -48,6 +49,7 @@ public class QueryGeneManiaTask extends AbstractTask {
4849
private static long lastTaxonomyId = 9606; // H.sapiens
4950

5051
@Inject private CommandExecutorTaskFactory commandExecutorTaskFactory;
52+
@Inject private SynchronousTaskManager<?> syncTaskManager;
5153

5254
public static interface Factory {
5355
QueryGeneManiaTask create(List<String> geneList, Set<String> leadingEdge);
@@ -121,7 +123,33 @@ public void allFinished(FinishStatus finishStatus) {
121123
// Never called by Cytoscape...
122124
}
123125
});
124-
insertTasksAfterCurrentTask(ti);
126+
127+
128+
// run the task right here so we can handle errors
129+
boolean[] timedOut = { false };
130+
Exception[] cause = { null };
131+
132+
syncTaskManager.execute(ti, new TaskObserver() {
133+
134+
@Override
135+
public void taskFinished(ObservableTask task) {
136+
}
137+
138+
@Override
139+
public void allFinished(FinishStatus finishStatus) {
140+
if(finishStatus.getType() == FinishStatus.Type.FAILED) {
141+
Exception ex = finishStatus.getException();
142+
if(ex != null && ex.getMessage() != null && ex.getMessage().contains("timeout")) {
143+
timedOut[0] = true;
144+
cause[0] = ex;
145+
}
146+
}
147+
}
148+
});
149+
150+
if(timedOut[0]) {
151+
throw new RuntimeException("GeneMANIA query timed out. Please try again with fewer genes.", cause[0]);
152+
}
125153

126154
// Save this as the default organism for next time
127155
lastTaxonomyId = organisms.getSelectedValue().getTaxonomyId();

0 commit comments

Comments
 (0)