<NME> middleware.py
<BEF> ADDFILE
<MSG> Simple way to display IMAP errors:
 * raise a specific exception in the imap connector,
 * Add a simple middleware to catch this exception and return a specific response that will be correctly displayed by the webmail.

see #127

<DFF> @@ -0,0 +1,11 @@
+# coding: utf-8
+
+from modoboa.lib import ajax_response
+from modoboa.extensions.webmail.lib import WebmailError
+
+class WebmailErrorMiddleware(object):
+    def process_exception(self, request, exception):
+        if not isinstance(exception, WebmailError):
+            return None
+        return ajax_response(request, status="ko", 
+                             error=str(exception), norefresh=True)

Simple way to display IMAP errors:  * raise a specific exception in the imap connector,  * Add a simple middleware to catch this exception and return a specific response that will be correctly displayed by the webmail.