From ec105008b6024da1125f8ab05edd888e86fecbff Mon Sep 17 00:00:00 2001 From: rabia23 Date: Thu, 28 Sep 2017 10:41:49 +0000 Subject: [PATCH] EDUCATOR-139 add log to identify the cause of error --- common/lib/xmodule/xmodule/x_module.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index b4a6e41264..2ed2848a1e 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -881,7 +881,21 @@ class XModule(HTMLSnippet, XModuleMixin): request_post[key] = map(FileObjForWebobFiles, request.POST.getall(key)) response_data = self.handle_ajax(suffix, request_post) - return Response(response_data, content_type='application/json') + + try: + return Response(response_data, content_type='application/json') + except TypeError: + request_environ = getattr(request, 'environ') + log.exception( + 'Response creation failed for problem url: %s, response_data type: %s, LANG: %s, ' + 'LC_ALL: %s and HTTP_ACCEPT_ENCODING: %s', + request_environ.get('HTTP_REFERER'), + type(response_data), + request_environ.get('LANG'), + request_environ.get('LC_ALL'), + request_environ.get('HTTP_ACCEPT_ENCODING') + ) + raise def get_child(self, usage_id): if usage_id in self._child_cache: