Better errors catching.

see #139
This commit is contained in:
Antoine Nguyen
2011-07-02 18:59:56 +02:00
parent 01153fa2c9
commit e38a2fc25b
2 changed files with 12 additions and 4 deletions
+6 -1
View File
@@ -14,7 +14,10 @@ class SieveClient(object):
__metaclass__ = ConnectionsManager
def __init__(self, user=None, password=None):
ret, msg = self.login(user, password)
try:
ret, msg = self.login(user, password)
except Error, e:
raise ConnectionError(str(e))
if not ret:
raise ConnectionError(msg)
@@ -29,6 +32,8 @@ class SieveClient(object):
try:
ret = self.msc.connect(user, password, use_starttls, authmech)
except Error, e:
ret = False
if not ret:
return False, _("Connection to MANAGESIEVE server failed, check your configuration")
return True, None
+6 -3
View File
@@ -1,5 +1,5 @@
# coding: utf-8
from sievelib.managesieve import Error
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _
@@ -18,8 +18,11 @@ def index(request, tplname="sievefilters/index.html"):
password=request.session["password"])
except ConnectionError, e:
return _render_error(request, user_context={"error" : e})
active_script, scripts = sc.listscripts()
try:
active_script, scripts = sc.listscripts()
except Error, e:
return _render_error(request, user_context={"error" : e})
if active_script is None:
active_script = ""
default_script = scripts[0] if len(scripts) else ""