Improve error messages for exam availability in Http404 responses

This commit is contained in:
Ross
2026-02-02 17:02:02 +00:00
parent e3241b503d
commit 3c0deec140
+4 -2
View File
@@ -783,10 +783,12 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
if self.start_date >= timezone.now() or (
self.end_date is not None and self.end_date <= timezone.now()
):
raise Http404("Exam not found")
# Raise with an explanatory message so the frontend can
# surface the reason to the end user.
raise Http404("Exam not currently available (outside allowed dates)")
# If it is not active no one can take
elif active_only and not self.active:
raise Http404("Exam not found")
raise Http404("Exam currently inactive")
# If candidates only check they have access
if self.candidates_only: