Skip to content

Commit

Permalink
update[DbWrapper]: add exception throwing for SQLException edgecase f…
Browse files Browse the repository at this point in the history
…or use in testing
  • Loading branch information
Lucy Ciara Herud-Thomassen authored and Lucy Ciara Herud-Thomassen committed Apr 21, 2026
1 parent b317fbd commit c4955de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/edu/group5/app/model/wrapper/DbWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ private List<Object[]> 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<Object[]> data) throws IllegalArgumentException {
public int exportDonations(List<Object[]> data) throws IllegalArgumentException, SQLException {
this.fetchAllDonations();

ParameterValidator.exportChecker(data, "data", this.donations, 6);
Expand Down Expand Up @@ -263,6 +265,7 @@ public int exportDonations(List<Object[]> 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);
}
Expand Down

0 comments on commit c4955de

Please sign in to comment.