Skip to content

Commit

Permalink
Catch more specific exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jingting1412 committed Oct 17, 2023
1 parent 4461d5f commit 878e594
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public boolean contains(Applicant toCheck) {
/**
* Adds a Applicant to the list.
* The Applicant must not already exist in the list.
* catches RuntimeExceptions such as:
* ClassCastException, NullPointerException, IllegalArgumentException
*/
public void add(Applicant toAdd) {
requireNonNull(toAdd);
Expand All @@ -53,7 +55,7 @@ public void add(Applicant toAdd) {
}
try {
internalList.add(toAdd);
} catch (Exception e) {
} catch (RuntimeException e) {
logger.info("Error adding applicant: " + StringUtil.getDetails(e));
}
}
Expand All @@ -62,6 +64,8 @@ public void add(Applicant toAdd) {
* Replaces the applicant {@code target} in the list with {@code editedApplicant}.
* {@code target} must exist in the list.
* The applicant identity of {@code editedApplicant} must not be the same as another existing applicant in the list.
* catches RuntimeExceptions such as:
* ClassCastException, NullPointerException, IllegalArgumentException, IndexOutOfBoundsException
*/
public void setApplicant(Applicant target, Applicant editedApplicant) {
requireAllNonNull(target, editedApplicant);
Expand All @@ -77,7 +81,7 @@ public void setApplicant(Applicant target, Applicant editedApplicant) {

try {
internalList.set(index, editedApplicant);
} catch (Exception e) {
} catch (RuntimeException e) {
logger.info("Error editing applicant: " + target.getName() + " " + StringUtil.getDetails(e));
}
}
Expand Down

0 comments on commit 878e594

Please sign in to comment.