Commit a6eddba9 authored by Florian Fuchs's avatar Florian Fuchs

catch Exception from mailman.client when failing to connect tp API

fix for lp:1021364
parents 294f8ff2 6cd5d16c
...@@ -21,7 +21,7 @@ import logging ...@@ -21,7 +21,7 @@ import logging
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.http import Http404 from django.http import Http404
from mailman.client import Client from mailman.client import Client, MailmanConnectionError
from urllib2 import HTTPError from urllib2 import HTTPError
...@@ -54,6 +54,8 @@ class MailmanRestManager(object): ...@@ -54,6 +54,8 @@ class MailmanRestManager(object):
return getattr(self.client, self.resource_name_plural) return getattr(self.client, self.resource_name_plural)
except AttributeError: except AttributeError:
raise MailmanApiError raise MailmanApiError
except MailmanConnectionError, e:
raise MailmanApiError(e)
def get(self, **kwargs): def get(self, **kwargs):
try: try:
...@@ -66,6 +68,9 @@ class MailmanRestManager(object): ...@@ -66,6 +68,9 @@ class MailmanRestManager(object):
raise Mailman404Error raise Mailman404Error
else: else:
raise raise
except MailmanConnectionError, e:
raise MailmanApiError(e)
def get_or_404(self, **kwargs): def get_or_404(self, **kwargs):
"""Similar to `self.get` but raises standard Django 404 error. """Similar to `self.get` but raises standard Django 404 error.
...@@ -74,6 +79,8 @@ class MailmanRestManager(object): ...@@ -74,6 +79,8 @@ class MailmanRestManager(object):
return self.get(**kwargs) return self.get(**kwargs)
except Mailman404Error: except Mailman404Error:
raise Http404 raise Http404
except MailmanConnectionError:
raise MailmanApiError
def create(self, **kwargs): def create(self, **kwargs):
try: try:
...@@ -86,6 +93,8 @@ class MailmanRestManager(object): ...@@ -86,6 +93,8 @@ class MailmanRestManager(object):
raise MailmanApiError raise MailmanApiError
else: else:
raise raise
except MailmanConnectionError:
raise MailmanApiError
def delete(self): def delete(self):
"""Not implemented since the objects returned from the API """Not implemented since the objects returned from the API
...@@ -104,6 +113,8 @@ class MailmanListManager(MailmanRestManager): ...@@ -104,6 +113,8 @@ class MailmanListManager(MailmanRestManager):
objects = getattr(self.client, self.resource_name_plural) objects = getattr(self.client, self.resource_name_plural)
except AttributeError: except AttributeError:
raise MailmanApiError raise MailmanApiError
except MailmanConnectionError, e:
raise MailmanApiError(e)
if only_public: if only_public:
public = [] public = []
for obj in objects: for obj in objects:
......
{% extends "postorius/base.html" %} {% extends "postorius/base.html" %}
{% load i18n %} {% load i18n %}
{% block header %} {% block main %}
<div class="mm_box mm_clear"> <h1>{% trans 'Something went wrong' %}</h1>
<div class="mm_boxHeader">{% trans "Error-Site" %}</div>
{% if error %}<p id="error">{{ error }}</p> {% endif %} {% if error %}<div class="alert alert-error">{{ error }}</div>{% endif %}
{% if message %}<p id="message">{{ message }}</p> {% endif %}
</div>
{% endblock %} {% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment