From c4955dea787a2947777370af829e639f9e2a42c7 Mon Sep 17 00:00:00 2001 From: Lucy Ciara Herud-Thomassen <86323303+LucyCiara@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:51:22 +0200 Subject: [PATCH] update[DbWrapper]: add exception throwing for SQLException edgecase for use in testing --- src/main/java/edu/group5/app/model/wrapper/DbWrapper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/group5/app/model/wrapper/DbWrapper.java b/src/main/java/edu/group5/app/model/wrapper/DbWrapper.java index f357ae1..fd2a2cc 100644 --- a/src/main/java/edu/group5/app/model/wrapper/DbWrapper.java +++ b/src/main/java/edu/group5/app/model/wrapper/DbWrapper.java @@ -230,8 +230,10 @@ private List importDonations(int user_id, boolean all) { * @throws IllegalArgumentException This exception is thrown when data is null, its rows are not * of length 6, any of the rows are null, any of the rows are duplicates or existing rows in * the database, or any of the values in the rows can't be cast to the correct data-types. + * @throws SQLException Is thrown when an unexpected exception like trying to export a number that's + * too big happens. */ - public int exportDonations(List data) throws IllegalArgumentException { + public int exportDonations(List data) throws IllegalArgumentException, SQLException { this.fetchAllDonations(); ParameterValidator.exportChecker(data, "data", this.donations, 6); @@ -263,6 +265,7 @@ public int exportDonations(List data) throws IllegalArgumentException this.logger.info("Donations exported"); } catch (SQLException e) { this.logger.log(Level.SEVERE, "Unexpected SQL exception", e); + throw new SQLException("An unexpected SQL exception has occurred. This might be caused by inserting an item that is too large."); } finally { this.close(null, ps); }