From 822eaa20c66764058d9e600ac435ba33b750bc64 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 8 Dec 2014 14:14:35 -0500 Subject: [PATCH] Make ErrorDescriptor more resistent to errors --- common/lib/xmodule/xmodule/error_module.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/error_module.py b/common/lib/xmodule/xmodule/error_module.py index 1391dc4ac2..066a1ad38b 100644 --- a/common/lib/xmodule/xmodule/error_module.py +++ b/common/lib/xmodule/xmodule/error_module.py @@ -108,7 +108,7 @@ class ErrorDescriptor(ErrorFields, XModuleDescriptor): cls, # The error module doesn't use scoped data, and thus doesn't need # real scope keys - ScopeIds('error', None, location, location), + ScopeIds(None, 'error', location, location), field_data, ) @@ -120,9 +120,14 @@ class ErrorDescriptor(ErrorFields, XModuleDescriptor): @classmethod def from_json(cls, json_data, system, location, error_msg='Error not available'): + try: + json_string = json.dumps(json_data, skipkeys=False, indent=4, cls=EdxJSONEncoder) + except: # pylint: disable=bare-except + json_string = repr(json_data) + return cls._construct( system, - json.dumps(json_data, skipkeys=False, indent=4, cls=EdxJSONEncoder), + json_string, error_msg, location=location )