Skip to content

Commit b88f64d

Browse files
committed
EGC-581 - updates exception handling
1 parent 588009d commit b88f64d

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

api/src/main/java/ca/bc/gov/educ/api/trax/service/BaseStudentMergeEventHandlerService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import ca.bc.gov.educ.api.trax.struct.StudentMerge;
1313
import ca.bc.gov.educ.api.trax.struct.GradStudent;
1414
import ca.bc.gov.educ.api.trax.util.JsonUtil;
15+
import ca.bc.gov.educ.api.trax.exception.NotificationApiException;
1516
import com.fasterxml.jackson.core.JsonProcessingException;
1617
import com.fasterxml.jackson.core.type.TypeReference;
1718
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -150,14 +151,18 @@ protected boolean checkStudentExistsInGradStudentApi(final String studentId) {
150151
log.info("Student {} not found in GRAD-STUDENT-API", studentId);
151152
return false;
152153
} else {
153-
throw new RuntimeException("GRAD-STUDENT-API error for student " + studentId + ": " + gradStudent.getException());
154+
throw new NotificationApiException("GRAD-STUDENT-API error for student " + studentId + ": " + gradStudent.getException());
154155
}
155156
}
156157
log.info("Student {} found in GRAD-STUDENT-API", studentId);
157158
return true;
159+
} catch (InterruptedException e) {
160+
Thread.currentThread().interrupt();
161+
log.error("Interrupted while checking student {}: {}", studentId, e.getMessage());
162+
throw new NotificationApiException("Interrupted while checking student " + studentId, e);
158163
} catch (Exception e) {
159164
log.error("Error checking student {}: {}", studentId, e.getMessage());
160-
throw new RuntimeException("Failed to check student " + studentId, e);
165+
throw new NotificationApiException("Failed to check student " + studentId, e);
161166
}
162167
}
163168

api/src/main/java/ca/bc/gov/educ/api/trax/service/StudentCreateMergeEventHandlerService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import ca.bc.gov.educ.api.trax.rest.RestUtils;
77
import ca.bc.gov.educ.api.trax.struct.EventType;
88
import ca.bc.gov.educ.api.trax.struct.Student;
9+
import ca.bc.gov.educ.api.trax.exception.NotificationApiException;
910
import lombok.extern.slf4j.Slf4j;
1011
import org.springframework.beans.factory.annotation.Autowired;
1112
import org.springframework.stereotype.Service;
@@ -62,7 +63,7 @@ protected void processStudentsMergeInfo(final Student student, final Student tru
6263
}
6364
} catch (Exception e) {
6465
log.error("Error checking student existence in GRAD-STUDENT-API for Student IDs: {} and {}", studentId, mergedToStudentId, e);
65-
throw new RuntimeException("Failed to check students. This should not have happened and will be retried.");
66+
throw new NotificationApiException("Failed to check students. This should not have happened and will be retried.", e);
6667
}
6768
}
6869

api/src/main/java/ca/bc/gov/educ/api/trax/service/StudentDeleteMergeEventHandlerService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import ca.bc.gov.educ.api.trax.rest.RestUtils;
77
import ca.bc.gov.educ.api.trax.struct.EventType;
88
import ca.bc.gov.educ.api.trax.struct.Student;
9+
import ca.bc.gov.educ.api.trax.exception.NotificationApiException;
910
import lombok.extern.slf4j.Slf4j;
1011
import org.springframework.beans.factory.annotation.Autowired;
1112
import org.springframework.stereotype.Service;
@@ -62,7 +63,7 @@ protected void processStudentsMergeInfo(final Student student, final Student tru
6263
}
6364
} catch (Exception e) {
6465
log.error("Error checking student existence in GRAD-STUDENT-API for Student IDs: {} and {}", studentId, mergedToStudentId, e);
65-
throw new RuntimeException("Failed to check students. This should not have happened and will be retried.");
66+
throw new NotificationApiException("Failed to check students. This should not have happened and will be retried.", e);
6667
}
6768
}
6869

0 commit comments

Comments
 (0)