Skip to content

Commit

Permalink
update[DbWrapper]: add exception throwing for exportUsers in case of …
Browse files Browse the repository at this point in the history
…SQLException
  • Loading branch information
Lucy Ciara Herud-Thomassen authored and Lucy Ciara Herud-Thomassen committed Apr 21, 2026
1 parent f0430cd commit d6016d5
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 @@ -132,8 +132,10 @@ public List<Object[]> importUsers() {
* @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 exportUsers(List<Object[]> data) throws IllegalArgumentException {
public int exportUsers(List<Object[]> data) throws IllegalArgumentException, SQLException {
this.importUsers();

ParameterValidator.exportChecker(data, "data", this.users, 6);
Expand Down Expand Up @@ -163,6 +165,7 @@ public int exportUsers(List<Object[]> data) throws IllegalArgumentException {
this.logger.info("Users 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 d6016d5

Please sign in to comment.