From 71a4ce876401fa239671ae32dbb53c05fb4acdbc Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 25 Sep 2016 14:52:47 +0200 Subject: server/func: handle download errors --- server/szurubooru/func/net.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/szurubooru/func/net.py b/server/szurubooru/func/net.py index 65c01c0..62ac4c3 100644 --- a/server/szurubooru/func/net.py +++ b/server/szurubooru/func/net.py @@ -1,9 +1,13 @@ import urllib.request +from szurubooru import errors def download(url): assert url request = urllib.request.Request(url) request.add_header('Referer', url) - with urllib.request.urlopen(request) as handle: - return handle.read() + try: + with urllib.request.urlopen(request) as handle: + return handle.read() + except Exception as e: + raise errors.ProcessingError('Error downloading %s (%s)' % (url, e)) -- cgit v1.3