Skip to content

Commit

Permalink
Error handling on the default offerte text
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard van Heest authored and Richard van Heest committed Jul 26, 2015
1 parent 1a59662 commit c786833
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
import java.io.IOException;

import javafx.event.ActionEvent;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonBar.ButtonData;

import org.apache.log4j.Logger;
import org.rekeningsysteem.exception.NoSuchFileException;
import org.rekeningsysteem.logging.ApplicationLogger;
import org.rekeningsysteem.logic.offerte.DefaultOfferteTextHandler;

import rx.Observable;
Expand All @@ -13,6 +19,8 @@ public class DefaultOfferteTextPaneController {

private final DefaultOfferteTextPane ui;
private final DefaultOfferteTextHandler handler = new DefaultOfferteTextHandler();

private final Logger logger = ApplicationLogger.getInstance();

public DefaultOfferteTextPaneController() {
this.ui = new DefaultOfferteTextPane();
Expand All @@ -29,10 +37,16 @@ public DefaultOfferteTextPaneController() {
this.handler.setDefaultText(s);
}
catch (IOException e) {
e.printStackTrace();
this.logger.error("Error while writing default offerte text to file.", e);
}
catch (NoSuchFileException e) {
e.printStackTrace();
String alertText = "De tekst kon niet worden opgeslagen. Raadpleeg "
+ "de programmeur om dit probleem op te lossen.";
ButtonType close = new ButtonType("Sluit", ButtonData.CANCEL_CLOSE);
Alert alert = new Alert(AlertType.NONE, alertText, close);
alert.setHeaderText("Fout bij opslaan");
alert.show();
this.logger.error(e.getMessage() + "\n" + "De tekst was: \"" + s + "\"\n", e);
}
});
cancel.subscribe(e -> {
Expand Down

0 comments on commit c786833

Please sign in to comment.