Commit b1e05c75 by Alan Boudreault

minor change to the try/except

parent f4611071
...@@ -180,24 +180,25 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -180,24 +180,25 @@ class MentoringBlock(XBlockWithLightChildren):
xml_content = submissions['xml_content'] xml_content = submissions['xml_content']
try: try:
xml = etree.parse(StringIO(xml_content)) xml = etree.parse(StringIO(xml_content))
root = xml.getroot()
self.url_name = root.attrib['url_name']
except etree.XMLSyntaxError as e: except etree.XMLSyntaxError as e:
response = { response = {
'result': 'error', 'result': 'error',
'message': e.message 'message': e.message
} }
except KeyError as e:
response = {
'result': 'error',
'message': 'mentoring "url_name" attribute is missing'
}
else: else:
response = { response = {
'result': 'success', 'result': 'success',
} }
self.xml_content = xml_content self.xml_content = xml_content
try:
self.url_name = xml.getroot().attrib['url_name']
except KeyError as e:
response = {
'result': 'error',
'message': 'mentoring "url_name" attribute is missing'
}
log.debug(u'Response from Studio: {}'.format(response)) log.debug(u'Response from Studio: {}'.format(response))
return response return response
......
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