From 205a67b858f02b18ba1c8104cc0951df514a2981 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 10 Jul 2015 17:17:55 +0200 Subject: Management of connection errors when adding a new feed. --- pyaggr3g470r/views/feed.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'pyaggr3g470r/views') diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py index e9827668..f5b48a17 100644 --- a/pyaggr3g470r/views/feed.py +++ b/pyaggr3g470r/views/feed.py @@ -1,6 +1,7 @@ #! /usr/bin/env python # -*- coding: utf-8 - import base64 +import requests.exceptions from hashlib import md5 from datetime import datetime from sqlalchemy import desc @@ -102,7 +103,11 @@ def bookmarklet(): "warning") return redirect(url_for('feed.form', feed_id=feed_exists[0].id)) - feed = construct_feed_from(url) + try: + feed = construct_feed_from(url) + except requests.exceptions.ConnectionError as e: + flash(gettext("Impossible to connect to the address: {}.".format(url)), "danger") + return redirect(url_for('home')) if not feed.get('link'): feed['enabled'] = False flash(gettext("Couldn't find a feed url, you'll need to find a Atom or" -- cgit