Commit 02ddeed7 by Victor Shnayder

better error handling in index view

parent d4c0516c
...@@ -208,7 +208,7 @@ def index(request, course_id, chapter=None, section=None, ...@@ -208,7 +208,7 @@ def index(request, course_id, chapter=None, section=None,
log.warning("TEMP: course_id {}, chap {}, sec {}, first_time {}, course position = {}" log.warning("TEMP: course_id {}, chap {}, sec {}, first_time {}, course position = {}"
.format(course_id, chapter, section, first_time, course_module.position)) .format(course_id, chapter, section, first_time, course_module.position))
if chapter is None and section is None: if chapter is None:
return redirect_to_course_position(course_module, first_time) return redirect_to_course_position(course_module, first_time)
context = { context = {
...@@ -225,9 +225,14 @@ def index(request, course_id, chapter=None, section=None, ...@@ -225,9 +225,14 @@ def index(request, course_id, chapter=None, section=None,
if chapter_descriptor is not None: if chapter_descriptor is not None:
instance_module = get_instance_module(course_id, request.user, course_module, student_module_cache) instance_module = get_instance_module(course_id, request.user, course_module, student_module_cache)
save_child_position(course_module, chapter, instance_module) save_child_position(course_module, chapter, instance_module)
else:
raise Http404
chapter_module = get_module(request.user, request, chapter_descriptor.location, chapter_module = get_module(request.user, request, chapter_descriptor.location,
student_module_cache, course_id) student_module_cache, course_id)
if chapter_module is None:
# User may be trying to access a chapter that isn't live yet
raise Http404
if section is not None: if section is not None:
section_descriptor = chapter_descriptor.get_child_by_url_name(section) section_descriptor = chapter_descriptor.get_child_by_url_name(section)
...@@ -267,7 +272,11 @@ def index(request, course_id, chapter=None, section=None, ...@@ -267,7 +272,11 @@ def index(request, course_id, chapter=None, section=None,
'prev_section_url': prev_section_url}) 'prev_section_url': prev_section_url})
result = render_to_response('courseware/courseware.html', context) result = render_to_response('courseware/courseware.html', context)
except: except Exception as e:
if isinstance(e, Http404):
# let it propagate
raise
# In production, don't want to let a 500 out for any reason # In production, don't want to let a 500 out for any reason
if settings.DEBUG: if settings.DEBUG:
raise raise
......
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