Skip to content

Commit

Permalink
feat: show exception message from filters in the user interface
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemontoya committed Aug 30, 2024
1 parent ea596d6 commit 1d8e622
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/djangoapps/student/models/course_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ def enroll(cls, user, course_key, mode=None, check_access=False, can_upgrade=Fal
Also emits relevant events for analytics purposes.
"""
try:
# .. filter_implemented_name: CourseEnrollmentStarted
# .. filter_type: org.openedx.learning.course.enrollment.started.v1
user, course_key, mode = CourseEnrollmentStarted.run_filter(
user=user, course_key=course_key, mode=mode,
)
Expand Down
3 changes: 3 additions & 0 deletions common/djangoapps/student/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
from common.djangoapps.student.models import ( # lint-amnesty, pylint: disable=unused-import
AccountRecovery,
CourseEnrollment,
EnrollmentNotAllowed,
PendingEmailChange, # unimport:skip
PendingSecondaryEmailChange,
Registration,
Expand Down Expand Up @@ -422,6 +423,8 @@ def change_enrollment(request, check_access=True):
enroll_mode = CourseMode.auto_enroll_mode(course_id, available_modes)
if enroll_mode:
CourseEnrollment.enroll(user, course_id, check_access=check_access, mode=enroll_mode)
except EnrollmentNotAllowed as exec: # pylint: disable=broad-except
return HttpResponseBadRequest(str(exec))
except Exception: # pylint: disable=broad-except
return HttpResponseBadRequest(_("Could not enroll"))

Expand Down

0 comments on commit 1d8e622

Please sign in to comment.