From 5607d2086d2c46b8106374d078c1d601911abe7e Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Wed, 27 May 2020 20:41:16 +0200 Subject: [PATCH] Added error handling for cover upload --- cps/helper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cps/helper.py b/cps/helper.py index a4715033..5a284910 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -532,7 +532,14 @@ def get_book_cover_internal(book, use_generic_cover_on_failure): # saves book cover from url def save_cover_from_url(url, book_path): - img = requests.get(url, timeout=10) # ToDo: Error Handling + try: + img = requests.get(url, timeout=(10, 200)) # ToDo: Error Handling + img.raise_for_status() + except (requests.exceptions.HTTPError, + requests.exceptions.ConnectionError, + requests.exceptions.Timeout) as ex: + log.info(u'Cover Download Error %s', ex) + return False, _("Error Downloading Cover") return save_cover(img, book_path)