Skip to content

Commit

Permalink
Added error handling for all solvers.
Browse files Browse the repository at this point in the history
  • Loading branch information
KingZee committed Aug 11, 2019
1 parent a56a772 commit a817011
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/scheduler/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,30 @@ private void onSolved(Event event) {

private void onFailed(Event event){
WorkerStateEvent worker = (WorkerStateEvent) event;
Throwable error = worker.getSource().getException();

List<Node> children = outputContainer.getChildren();
while (children.size() > 1){
Node node = children.get(0);
if(!(node instanceof TextFlow)){
children.remove(node);
}
}

TextFlow textnode = (TextFlow) children.get(0);
textnode.getChildren().clear();

if(error instanceof IllegalArgumentException && error.getMessage().contains("Cartesian product too large")){
textnode.getChildren().add(outputText("Error : Matrix is too big to be solved by this solver."));
} else if(error instanceof OutOfMemoryError){
textnode.getChildren().add(outputText("Error : Program ran out of memory."));
} else {
textnode.getChildren().add(outputText("Error : "+error.getLocalizedMessage()));
}

resetCalculateButton();
TitledPane out = ((Accordion) main.getChildren().get(0)).getPanes().get(1);
((Accordion) main.getChildren().get(0)).setExpandedPane(out);
System.out.println("Event failed!");
}

Expand Down

0 comments on commit a817011

Please sign in to comment.