Include stack trace in Course Rerun errors; Log errors.
This commit is contained in:
@@ -5,6 +5,7 @@ This file contains celery tasks for contentstore views
|
||||
from celery.task import task
|
||||
from django.contrib.auth.models import User
|
||||
import json
|
||||
import logging
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.course_module import CourseFields
|
||||
|
||||
@@ -40,13 +41,15 @@ def rerun_course(source_course_key_string, destination_course_key_string, user_i
|
||||
|
||||
except DuplicateCourseError as exc:
|
||||
# do NOT delete the original course, only update the status
|
||||
CourseRerunState.objects.failed(course_key=destination_course_key, exception=exc)
|
||||
CourseRerunState.objects.failed(course_key=destination_course_key)
|
||||
logging.exception(u'Course Rerun Error')
|
||||
return "duplicate course"
|
||||
|
||||
# catch all exceptions so we can update the state and properly cleanup the course.
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
# update state: Failed
|
||||
CourseRerunState.objects.failed(course_key=destination_course_key, exception=exc)
|
||||
CourseRerunState.objects.failed(course_key=destination_course_key)
|
||||
logging.exception(u'Course Rerun Error')
|
||||
|
||||
try:
|
||||
# cleanup any remnants of the course
|
||||
|
||||
@@ -1699,6 +1699,18 @@ class RerunCourseTest(ContentStoreTestCase):
|
||||
self.user.save()
|
||||
self.post_rerun_request(source_course.id, response_code=403, expect_error=True)
|
||||
|
||||
def test_rerun_error(self):
|
||||
error_message = "Mock Error Message"
|
||||
with mock.patch(
|
||||
'xmodule.modulestore.mixed.MixedModuleStore.clone_course',
|
||||
mock.Mock(side_effect=Exception(error_message))
|
||||
):
|
||||
source_course = CourseFactory.create()
|
||||
destination_course_key = self.post_rerun_request(source_course.id)
|
||||
rerun_state = CourseRerunState.objects.find_first(course_key=destination_course_key)
|
||||
self.assertEquals(rerun_state.state, CourseRerunUIStateManager.State.FAILED)
|
||||
self.assertIn(error_message, rerun_state.message)
|
||||
|
||||
|
||||
class EntryPageTestCase(TestCase):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user