From 40545441264a26deb007110ab99ba55034a7cdf0 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 7 Aug 2013 22:26:00 -0400 Subject: [PATCH] handle exceptions inside the outer exception handling --- cms/djangoapps/contentstore/views/assets.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cms/djangoapps/contentstore/views/assets.py b/cms/djangoapps/contentstore/views/assets.py index c2da87d0aa..bbaea74ce5 100644 --- a/cms/djangoapps/contentstore/views/assets.py +++ b/cms/djangoapps/contentstore/views/assets.py @@ -346,13 +346,20 @@ def generate_export_course(request, org, course, name): try: export_to_xml(modulestore('direct'), contentstore(), loc, root_dir, name, modulestore()) except SerializationError, e: - failed_item = modulestore().get_instance(course_module.location.course_id, e.location) - parent_locs = modulestore().get_parent_locations(failed_item.location, course_module.location.course_id) unit = None - if len(parent_locs) > 0: - parent = modulestore().get_item(parent_locs[0]) - if parent.location.category == 'vertical': - unit = parent + failed_item = None + parent = None + try: + failed_item = modulestore().get_instance(course_module.location.course_id, e.location) + parent_locs = modulestore().get_parent_locations(failed_item.location, course_module.location.course_id) + + if len(parent_locs) > 0: + parent = modulestore().get_item(parent_locs[0]) + if parent.location.category == 'vertical': + unit = parent + except: + # if we have a nested exception, then we'll show the more generic error message + pass return render_to_response('export.html', { 'context_course': course_module, @@ -363,7 +370,7 @@ def generate_export_course(request, org, course, name): 'unit': unit, 'edit_unit_url': reverse('edit_unit', kwargs={ 'location': parent.location - }), + }) if parent else '', 'course_home_url': reverse('course_index', kwargs={ 'org': org, 'course': course,