1
0
Fork 0

models/Observation: Improve requests exception handling (W0703)

Fixes a broad-except (W0703) pylint error.

Signed-off-by: Fabian P. Schmidt <kerel@mailbox.org>
merge-requests/870/head
Fabian P. Schmidt 2020-01-02 22:38:48 +01:00
parent caa861b187
commit 4c9cd66661
1 changed files with 3 additions and 1 deletions

View File

@ -515,9 +515,11 @@ class Observation(models.Model):
if self.archive_url:
try:
request = requests.get(self.archive_url, allow_redirects=False)
request.raise_for_status()
url = request.headers['Location']
return url
except Exception as error:
except requests.exceptions.RequestException as error:
logger = logging.getLogger(__name__)
logger.warning("Error in request to '%s'. Error: %s", self.archive_url, error)
return ''