From 8bf2eb17e848fa8a53b26b992c4948e61a8005c1 Mon Sep 17 00:00:00 2001 From: Rocky Duan Date: Mon, 30 Jul 2012 17:17:09 -0400 Subject: [PATCH] middleware file forgot to include --- lms/djangoapps/django_comment_client/middleware.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 lms/djangoapps/django_comment_client/middleware.py diff --git a/lms/djangoapps/django_comment_client/middleware.py b/lms/djangoapps/django_comment_client/middleware.py new file mode 100644 index 0000000000..08e20b0296 --- /dev/null +++ b/lms/djangoapps/django_comment_client/middleware.py @@ -0,0 +1,9 @@ +from comment_client import CommentClientError +from django_comment_client.utils import JsonError +import json + +class AjaxExceptionMiddleware(object): + def process_exception(self, request, exception): + if isinstance(exception, CommentClientError) and request.is_ajax(): + return JsonError(json.loads(exception.message)) + return None