Commit 5be4fa30 by Tim Krones

Catch IndexError that gets thrown when user provides invalid root block ID.

parent 4a9a6d44
...@@ -6,7 +6,6 @@ import time ...@@ -6,7 +6,6 @@ import time
from celery.task import task from celery.task import task
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from instructor_task.models import ReportStore from instructor_task.models import ReportStore
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from student.models import user_by_anonymous_id from student.models import user_by_anonymous_id
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
...@@ -31,9 +30,7 @@ def export_data(course_id, source_block_id_str, block_types, user_id, match_stri ...@@ -31,9 +30,7 @@ def export_data(course_id, source_block_id_str, block_types, user_id, match_stri
try: try:
course_key = CourseKey.from_string(course_id) course_key = CourseKey.from_string(course_id)
src_block = modulestore().get_items(course_key, qualifiers={'name': source_block_id_str}, depth=0)[0] src_block = modulestore().get_items(course_key, qualifiers={'name': source_block_id_str}, depth=0)[0]
if src_block is None: except IndexError:
raise InvalidKeyError
except InvalidKeyError:
raise ValueError("Could not find the specified Block ID.") raise ValueError("Could not find the specified Block ID.")
course_key_str = unicode(course_key) course_key_str = unicode(course_key)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment