aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominic Rogetzer <e1627756@student.tuwien.ac.at>2018-06-17 12:07:00 +0200
committerTharre <tharre3@gmail.com>2018-06-17 19:50:47 +0200
commit071bc85d8a3593a2de8b1e16091428a77bbe6c68 (patch)
treea87dbcf7bf98d348c1efc7f883516a6af7d4034f
parentb9521966604a101a50b2e9ac52d1f7a9f772b136 (diff)
downloadsepm-groupproject-071bc85d8a3593a2de8b1e16091428a77bbe6c68.tar.gz
sepm-groupproject-071bc85d8a3593a2de8b1e16091428a77bbe6c68.tar.xz
sepm-groupproject-071bc85d8a3593a2de8b1e16091428a77bbe6c68.zip
Separate validation errors from exceptions w.r.t logging, alert [#25963]
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java
index 81437f5..8cebeab 100644
--- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java
+++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java
@@ -164,14 +164,12 @@ public class CreateOperationController {
fpVehicles.getChildren().add(controller.getRootElement());
}
- } catch (ServiceException | IOException | InvalidOperationException e) {
+ } catch (ServiceException | IOException e) {
LOG.error("Exception in updateList(). ", e);
-
- Alert alert = new Alert(Alert.AlertType.ERROR);
- alert.setTitle("Fehler");
- alert.setHeaderText("Fehler!");
- alert.setContentText(e.getMessage());
- alert.showAndWait();
+ showAlert(AlertType.ERROR, "Fehler", e.getMessage());
+ } catch (InvalidOperationException e) {
+ LOG.debug("Validation error in updateList(). ", e);
+ showAlert(AlertType.ERROR, "Validierungsfehler", e.getMessage());
}
try {
lvActiveOperations.setItems(
@@ -179,11 +177,10 @@ public class CreateOperationController {
operationService.list(EnumSet.of(Status.ACTIVE))));
} catch (ServiceException e) {
LOG.error("ServiceException in updateList(). ", e);
- Alert alert = new Alert(Alert.AlertType.ERROR);
- alert.setTitle("Fehler - Einsätze");
- alert.setHeaderText("Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten.");
- alert.setContentText(e.getMessage());
- alert.showAndWait();
+ showAlert(
+ AlertType.ERROR,
+ "Fehler",
+ "Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten");
}
}
@@ -276,20 +273,19 @@ public class CreateOperationController {
.build();
try {
operationService.add(operation);
- } catch (ServiceException | InvalidOperationException e) {
+ } catch (ServiceException e) {
LOG.error("Exception in createOperationClicked(). ", e);
- Alert alert = new Alert(Alert.AlertType.ERROR);
- alert.setTitle("Fehler");
- alert.setHeaderText("Fehler!");
- alert.setContentText(e.getMessage());
- alert.showAndWait();
+ showAlert(AlertType.ERROR, "Fehler", e.getMessage());
+ return;
+ } catch (InvalidOperationException e) {
+ LOG.debug("Validation error in createOperationClicked(). ", e);
+ showAlert(AlertType.ERROR, "Validierungsfehler", e.getMessage());
return;
}
- Alert alert = new Alert(AlertType.CONFIRMATION);
- alert.setTitle("Erfolg");
- alert.setHeaderText("Erfolgreich gespeichert");
- alert.setContentText("Der Einsatz wurde erfolgreich gespeichert.");
- alert.showAndWait();
+ showAlert(
+ AlertType.CONFIRMATION,
+ "Erfolgreich gespeichert",
+ "Der Einsatz wurde erfolgreich gespeichert.");
updateList();
lblChosenVehicles.setText("keine ausgewählt");
txtAddress.setText("");
@@ -298,6 +294,14 @@ public class CreateOperationController {
chosenVehicles = new LinkedList<>();
}
+ private void showAlert(AlertType alertType, String title, String content) {
+ Alert alert = new Alert(alertType);
+ alert.setTitle(title);
+ alert.setHeaderText(title);
+ alert.setContentText(content);
+ alert.showAndWait();
+ }
+
public void onRegistrationLinkClicked(ActionEvent actionEvent) {
LOG.debug("Hyperlink \"Anmeldungen\" clicked.");
openRegistrationWindow();