1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-11-04 09:22:29 +01:00

Additionally catch HTTPError and RequestException

Concerns issue #26.
This commit is contained in:
André Koch-Kramer 2017-08-01 16:30:59 +02:00
parent 0ad50c1526
commit c3a5557140

View File

@ -21,6 +21,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple
import requests import requests
import requests.utils import requests.utils
import urllib3
# To get version from setup.py for instaloader --version # To get version from setup.py for instaloader --version
@ -164,7 +165,7 @@ class Instaloader:
shutil.copyfileobj(resp.raw, file) shutil.copyfileobj(resp.raw, file)
else: else:
raise ConnectionException("Request returned HTTP error code {}.".format(resp.status_code)) raise ConnectionException("Request returned HTTP error code {}.".format(resp.status_code))
except (ConnectionResetError, ConnectionException) as err: except (urllib3.exceptions.HTTPError, requests.exceptions.RequestException, ConnectionException) as err:
print("URL: " + url + "\n" + err, file=sys.stderr) print("URL: " + url + "\n" + err, file=sys.stderr)
if tries <= 1: if tries <= 1:
raise err raise err