From 7884e7dfb93b6555f9470734209b4f188ee7a937 Mon Sep 17 00:00:00 2001 From: Felix Kehrer Date: Wed, 20 Jun 2018 20:33:52 +0200 Subject: Handle validation errors differently from other Exceptions #28864 --- .../controller/OperationDetailsController.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/ac') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java index 937a86a..daeaedd 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java @@ -89,9 +89,12 @@ public class OperationDetailsController { controller.getBtnRequest().setOnAction(e -> requestVehicleClicked(controller)); fpAdditional.getChildren().add(controller.getRootElement()); } - } catch (IOException | ServiceException | InvalidOperationException e) { + } catch (IOException | ServiceException e) { LOG.error("Error while updating list.", e); showServiceExceptionAlertAndWait("Error while updating list."); + } catch (InvalidOperationException e) { + LOG.debug("Validation for Operation failed"); + showValidationErrorAlertAndWait(e.getMessage()); } } @@ -160,17 +163,23 @@ public class OperationDetailsController { private void requestVehicleClicked(VehiclePaneController v) { LOG.debug("Button \"Nachfordern\" clicked."); - Vehicle vehicle; + Vehicle vehicle = null; try { vehicle = v.getData(); if (vehicle == null) return; operationService.requestVehicles(operation.id(), Set.of(vehicle.id())); - } catch (ServiceException | InvalidOperationException | InvalidVehicleException e) { - LOG.error("Exception in requestVehicleClicked()", e); + } catch (ServiceException e) { + LOG.error("ServiceException in requestVehicleClicked()", e); showServiceExceptionAlertAndWait(e.getMessage()); return; + } catch (InvalidVehicleException e) { + LOG.debug("Validation of Vehicle failed"); + showValidationErrorAlertAndWait(e.getMessage()); + } catch (InvalidOperationException e) { + LOG.debug("Validation of Operation failed"); + showValidationErrorAlertAndWait(e.getMessage()); } showSuccessAlertAndWait("Das Fahrzeug wurde erfolgreich angefordert"); operation.vehicles().add(vehicle); -- cgit v1.2.3-70-g09d2