From 3c0deec140e4fc748274f0f77bd9f67ffa838704 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 2 Feb 2026 17:02:02 +0000 Subject: [PATCH] Improve error messages for exam availability in Http404 responses --- generic/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/generic/models.py b/generic/models.py index c14ea5be..99ec9da4 100644 --- a/generic/models.py +++ b/generic/models.py @@ -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: