|
12 | 12 | import org.cytoscape.work.FinishStatus;
|
13 | 13 | import org.cytoscape.work.ObservableTask;
|
14 | 14 | import org.cytoscape.work.ProvidesTitle;
|
| 15 | +import org.cytoscape.work.SynchronousTaskManager; |
15 | 16 | import org.cytoscape.work.TaskIterator;
|
16 | 17 | import org.cytoscape.work.TaskMonitor;
|
17 | 18 | import org.cytoscape.work.TaskObserver;
|
@@ -48,6 +49,7 @@ public class QueryGeneManiaTask extends AbstractTask {
|
48 | 49 | private static long lastTaxonomyId = 9606; // H.sapiens
|
49 | 50 |
|
50 | 51 | @Inject private CommandExecutorTaskFactory commandExecutorTaskFactory;
|
| 52 | + @Inject private SynchronousTaskManager<?> syncTaskManager; |
51 | 53 |
|
52 | 54 | public static interface Factory {
|
53 | 55 | QueryGeneManiaTask create(List<String> geneList, Set<String> leadingEdge);
|
@@ -121,7 +123,33 @@ public void allFinished(FinishStatus finishStatus) {
|
121 | 123 | // Never called by Cytoscape...
|
122 | 124 | }
|
123 | 125 | });
|
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 | + } |
125 | 153 |
|
126 | 154 | // Save this as the default organism for next time
|
127 | 155 | lastTaxonomyId = organisms.getSelectedValue().getTaxonomyId();
|
|
0 commit comments