Commit d7766a7b by Calen Pennington

Fix AssertionErrors that were raised when creation of an XModule failed

The ErrorDescriptor wasn't getting the appropriate xmodule_runtime set,
and thus immediately raising an AssertionError when we tried to retrieve
and _xmodule from it.

[LMS-1388[
parent d41a9745
...@@ -735,11 +735,16 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock): ...@@ -735,11 +735,16 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
) )
self.xmodule_runtime.xmodule_instance.save() self.xmodule_runtime.xmodule_instance.save()
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
if isinstance(self, self.xmodule_runtime.error_descriptor_class):
log.exception('Error creating an ErrorModule from an ErrorDescriptor')
raise
log.exception('Error creating xmodule') log.exception('Error creating xmodule')
descriptor = self.xmodule_runtime.error_descriptor_class.from_descriptor( descriptor = self.xmodule_runtime.error_descriptor_class.from_descriptor(
self, self,
error_msg=exc_info_to_str(sys.exc_info()) error_msg=exc_info_to_str(sys.exc_info())
) )
descriptor.xmodule_runtime = self.xmodule_runtime
self.xmodule_runtime.xmodule_instance = descriptor._xmodule # pylint: disable=protected-access self.xmodule_runtime.xmodule_instance = descriptor._xmodule # pylint: disable=protected-access
return self.xmodule_runtime.xmodule_instance return self.xmodule_runtime.xmodule_instance
......
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