Skip to content

Commit

Permalink
temp: add temporary exception handling in course and course run apis …
Browse files Browse the repository at this point in the history
…to log the complete error (#4167)

* temp: add temporary exception handling in course and course run apis to log the complete error
  • Loading branch information
DawoudSheraz authored Oct 30, 2023
1 parent bdace1f commit 4e9386c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion course_discovery/apps/api/v1/views/course_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,13 @@ def _update_course_run(self, course_run, draft, changed, serializer, request, pr
if not draft and (course_run.status == CourseRunStatus.Unpublished or non_exempt_update):
save_kwargs['status'] = CourseRunStatus.LegalReview

course_run = serializer.save(**save_kwargs)
try:
course_run = serializer.save(**save_kwargs)
except Exception:
log.exception(
f"Exception raised when attempting to save course run {course_run.key} with arguments {save_kwargs}"
)
raise # re-raise the exception so that it is captured by writable_request_wrapper

if course_run in course_run.course.active_course_runs:
course_run.update_or_create_seats(course_run.type, prices, upgrade_deadline_override,)
Expand Down
10 changes: 8 additions & 2 deletions course_discovery/apps/api/v1/views/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,14 @@ def update_course(self, data, partial=False): # pylint: disable=too-many-statem
_('Course edit was unsuccessful. The course URL slug ‘[{url_slug}]’ is already in use. '
'Please update this field and try again.').format(url_slug=url_slug))

# Then the course itself
course = serializer.save()
try:
# Then the course itself
course = serializer.save()
except Exception:
logger.exception(
f"Exception raised when attempting to save course {course.key} with arguments {data}"
)
raise # re-raise the exception so that it is captured by writable_request_wrapper
if url_slug:
course.set_active_url_slug(url_slug)
if course.official_version and (not draft or self._is_course_run_reviewed(course)):
Expand Down

0 comments on commit 4e9386c

Please sign in to comment.