Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
fix: handle unregistered student as KO message
Browse files Browse the repository at this point in the history
  • Loading branch information
Lutonite committed Sep 3, 2024
1 parent 3eaf274 commit 4b19a37
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.presentium.backend.rpc;

import ch.presentium.backend.api.exception.ObjectNotFoundException;
import ch.presentium.backend.business.service.EnrollmentService;
import ch.presentium.backend.business.service.PresenceService;
import java.util.UUID;
Expand Down Expand Up @@ -47,7 +48,12 @@ public Mono<GenericResponse> studentPresence(Mono<PresenceStudent> request) {
return request
.publishOn(Schedulers.boundedElastic())
.map(req -> {
presenceService.addPresence(req.getCardId(), UUID.fromString(req.getSessionId()));
try {
presenceService.addPresence(req.getCardId(), UUID.fromString(req.getSessionId()));
} catch (ObjectNotFoundException e) {
return GenericResponse.newBuilder().setStatus("KO").setMessage("Unregistered student").build();
}

return GenericResponse.newBuilder().setStatus("OK").setMessage("Student presence verified").build();
});
}
Expand Down

0 comments on commit 4b19a37

Please sign in to comment.