Commit f3a58324 by Calen Pennington

Expect the proper error type when about or info sections aren't found

parent 29fc851c
from path import path from path import path
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.seq_module import SequenceDescriptor, SequenceModule from xmodule.seq_module import SequenceDescriptor, SequenceModule
from fs.errors import ResourceNotFoundError
class CourseDescriptor(SequenceDescriptor): class CourseDescriptor(SequenceDescriptor):
module_class = SequenceModule module_class = SequenceModule
...@@ -51,7 +52,7 @@ class CourseDescriptor(SequenceDescriptor): ...@@ -51,7 +52,7 @@ class CourseDescriptor(SequenceDescriptor):
try: try:
with self.system.resources_fs.open(path("about") / section_key + ".html") as htmlFile: with self.system.resources_fs.open(path("about") / section_key + ".html") as htmlFile:
return htmlFile.read() return htmlFile.read()
except IOError: except ResourceNotFoundError:
return "! About section missing !" return "! About section missing !"
elif section_key == "title": elif section_key == "title":
return self.metadata.get('display_name', self.name) return self.metadata.get('display_name', self.name)
...@@ -79,7 +80,7 @@ class CourseDescriptor(SequenceDescriptor): ...@@ -79,7 +80,7 @@ class CourseDescriptor(SequenceDescriptor):
try: try:
with self.system.resources_fs.open(path("info") / section_key + ".html") as htmlFile: with self.system.resources_fs.open(path("info") / section_key + ".html") as htmlFile:
return htmlFile.read() return htmlFile.read()
except IOError: except ResourceNotFoundError:
return "! About section missing !" return "! About section missing !"
raise KeyError("Invalid about key " + str(section_key)) raise KeyError("Invalid about key " + str(section_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