Files
modoboa/extensions/webmail/middleware.py
T
Antoine Nguyen 53f1cb5899 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
2011-03-28 17:12:12 +02:00

12 lines
398 B
Python

# 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)