From: Janis Streib Date: Fri, 25 Jul 2014 00:01:04 +0000 (+0200) Subject: UPD: Use gigiapiexceptions X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=3597cc66589155b9ab8122f5d0e8c28c28fb8b81 UPD: Use gigiapiexceptions --- diff --git a/src/org/cacert/gigi/User.java b/src/org/cacert/gigi/User.java index 0e1ee22c..1dd15011 100644 --- a/src/org/cacert/gigi/User.java +++ b/src/org/cacert/gigi/User.java @@ -291,16 +291,16 @@ public class User { } } - public void deleteEmail(EmailAddress mail) { + public void deleteEmail(EmailAddress mail) throws GigiApiException { if (getEmail().equals(mail.getAddress())) { - throw new IllegalArgumentException("Can't delete user's default e-mail."); + throw new GigiApiException("Can't delete user's default e-mail."); } try { PreparedStatement ps = DatabaseConnection.getInstance().prepare("DELETE FROM email WHERE id=?"); ps.setInt(1, mail.getId()); ps.execute(); } catch (SQLException e) { - e.printStackTrace(); + throw new GigiApiException(e); } } } diff --git a/src/org/cacert/gigi/pages/account/MailManagementForm.java b/src/org/cacert/gigi/pages/account/MailManagementForm.java index 9dc6c8da..a36189ea 100644 --- a/src/org/cacert/gigi/pages/account/MailManagementForm.java +++ b/src/org/cacert/gigi/pages/account/MailManagementForm.java @@ -6,10 +6,12 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.cacert.gigi.EmailAddress; +import org.cacert.gigi.GigiApiException; import org.cacert.gigi.Language; import org.cacert.gigi.User; import org.cacert.gigi.output.Form; import org.cacert.gigi.output.template.Template; +import org.cacert.gigi.pages.Page; public class MailManagementForm extends Form { private static Template t; @@ -32,8 +34,8 @@ public class MailManagementForm extends Form { return false; } target.updateDefaultEmail(EmailAddress.getById(Integer.parseInt(mailid.trim()))); - } catch (Exception e) { - out.println("
Error precessing your request.
"); + } catch (GigiApiException e) { + e.format(out, Page.getLanguage(req)); e.printStackTrace(); return false; } @@ -47,8 +49,8 @@ public class MailManagementForm extends Form { for (int i = 0; i < toDel.length; i++) { try { target.deleteEmail(EmailAddress.getById(Integer.parseInt(toDel[i].trim()))); - } catch (Exception e) { - out.println("
Error precessing your request.
"); + } catch (GigiApiException e) { + e.format(out, Page.getLanguage(req)); e.printStackTrace(); return false; }