From 3b891c4a87b178dfd430d73bd2b99d44f6a087fb Mon Sep 17 00:00:00 2001 From: Johann Maierhofer <126261667+JohannMaierhofer@users.noreply.github.com> Date: Mon, 22 Jan 2024 08:22:53 +0100 Subject: [PATCH] Try/Catch Handling angepasst (#112) * Try/Catch Handling angepasst Try/Catch Handling entsprechend dem Kommentar von willuhn aus Pull request #104 commit d8cebbf angepasst * Und wieder import java.rmi.RemoteException entfernt --- .../BuchungMitgliedskontoZuordnungAction.java | 99 +++++++++---------- 1 file changed, 44 insertions(+), 55 deletions(-) diff --git a/src/de/jost_net/JVerein/gui/action/BuchungMitgliedskontoZuordnungAction.java b/src/de/jost_net/JVerein/gui/action/BuchungMitgliedskontoZuordnungAction.java index 7cf177f9c..e7ed56866 100644 --- a/src/de/jost_net/JVerein/gui/action/BuchungMitgliedskontoZuordnungAction.java +++ b/src/de/jost_net/JVerein/gui/action/BuchungMitgliedskontoZuordnungAction.java @@ -17,8 +17,6 @@ package de.jost_net.JVerein.gui.action; -import java.rmi.RemoteException; - import de.jost_net.JVerein.Einstellungen; import de.jost_net.JVerein.gui.control.BuchungsControl; import de.jost_net.JVerein.gui.dialogs.MitgliedskontoAuswahlDialog; @@ -76,71 +74,62 @@ public void handleAction(Object context) throws ApplicationException { return; } - try + MitgliedskontoAuswahlDialog mkaz = new MitgliedskontoAuswahlDialog(b[0]); + Object open = mkaz.open(); + Mitgliedskonto mk = null; + + if (!mkaz.getAbort()) { - MitgliedskontoAuswahlDialog mkaz = new MitgliedskontoAuswahlDialog(b[0]); - Object open = mkaz.open(); - Mitgliedskonto mk = null; - - if (!mkaz.getAbort()) + if (open instanceof Mitgliedskonto) { - if (open instanceof Mitgliedskonto) - { - mk = (Mitgliedskonto) open; - } - else if (open instanceof Mitglied) - { - Mitglied m = (Mitglied) open; - mk = (Mitgliedskonto) Einstellungen.getDBService().createObject( - Mitgliedskonto.class, null); - - Double betrag = 0d; - for (Buchung buchung : b) - { - betrag += buchung.getBetrag(); - } - - mk.setBetrag(betrag); - mk.setDatum(b[0].getDatum()); - mk.setMitglied(m); - mk.setZahlungsweg(Zahlungsweg.ÜBERWEISUNG); - mk.setZweck1(b[0].getZweck()); - mk.store(); - } + mk = (Mitgliedskonto) open; + } + else if (open instanceof Mitglied) + { + Mitglied m = (Mitglied) open; + mk = (Mitgliedskonto) Einstellungen.getDBService().createObject( + Mitgliedskonto.class, null); + Double betrag = 0d; for (Buchung buchung : b) { - buchung.setMitgliedskonto(mk); - buchung.store(); - } - control.getBuchungsList(); - - if (mk == null) - { - GUI.getStatusBar().setSuccessText("Mitgliedskonto gelöscht"); - } - else - { - GUI.getStatusBar().setSuccessText("Mitgliedskonto zugeordnet"); + betrag += buchung.getBetrag(); } + + mk.setBetrag(betrag); + mk.setDatum(b[0].getDatum()); + mk.setMitglied(m); + mk.setZahlungsweg(Zahlungsweg.ÜBERWEISUNG); + mk.setZweck1(b[0].getZweck()); + mk.store(); } - } - catch (Exception e) - { - if (!(e instanceof OperationCanceledException)) + + for (Buchung buchung : b) { - Logger.error("Fehler", e); - GUI.getStatusBar().setErrorText( - "Fehler bei der Zuordnung des Mitgliedskontos"); + buchung.setMitgliedskonto(mk); + buchung.store(); + } + control.getBuchungsList(); + + if (mk == null) + { + GUI.getStatusBar().setSuccessText("Mitgliedskonto gelöscht"); + } + else + { + GUI.getStatusBar().setSuccessText("Mitgliedskonto zugeordnet"); } - return; } } - catch (RemoteException e) + catch (OperationCanceledException oce) + { + throw oce; + } + catch (Exception e) { - String fehler = "Fehler beim Speichern."; - GUI.getStatusBar().setErrorText(fehler); - Logger.error(fehler, e); + Logger.error("Fehler", e); + GUI.getStatusBar().setErrorText( + "Fehler bei der Zuordnung des Mitgliedskontos"); } } }