From 9cea3f971f158a25ea7b0ba76e28eaee014b48e2 Mon Sep 17 00:00:00 2001
From: ichuang
Date: Sun, 24 Jun 2012 12:40:56 -0400
Subject: [PATCH] improved error handling - catch errors around lcp.get_html()
---
common/lib/xmodule/capa_module.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/common/lib/xmodule/capa_module.py b/common/lib/xmodule/capa_module.py
index ad20364a06..c12446e744 100644
--- a/common/lib/xmodule/capa_module.py
+++ b/common/lib/xmodule/capa_module.py
@@ -117,7 +117,18 @@ class Module(XModule):
'''Return html for the problem. Adds check, reset, save buttons
as necessary based on the problem config and state.'''
- html = self.lcp.get_html()
+ try:
+ html = self.lcp.get_html()
+ except Exception, err:
+ if self.DEBUG:
+ log.exception(err)
+ msg = '[courseware.capa.capa_module] Failed to generate HTML for problem %s' % (self.filename)
+ msg += 'Error:
%s
' % str(err).replace('<','<')
+ msg += '%s
' % traceback.format_exc().replace('<','<')
+ html = msg
+ else:
+ raise
+
content = {'name': self.name,
'html': html,
'weight': self.weight,