From 7215ca6a1a541a1cc41a9432aafff7e06307648a Mon Sep 17 00:00:00 2001 From: Francis Charette-Migneault Date: Tue, 14 Nov 2023 19:38:30 -0500 Subject: [PATCH] Update STACpopulator/api_requests.py Co-authored-by: David Huard --- STACpopulator/api_requests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/STACpopulator/api_requests.py b/STACpopulator/api_requests.py index 69fa292..793fd03 100644 --- a/STACpopulator/api_requests.py +++ b/STACpopulator/api_requests.py @@ -22,8 +22,8 @@ def stac_host_reachable(url: str, session: Optional[Session] = None) -> bool: response = session.get(url, headers={"Accept": "application/json"}) response.raise_for_status() body = response.json() - if body["type"] == "Catalog" and "stac_version" in body: - return True + return body["type"] == "Catalog" and "stac_version" in body + except (requests.exceptions.RequestException, requests.exceptions.ConnectionError) as exc: LOGGER.error("Could not validate STAC host. Not reachable [%s] due to [%s]", url, exc, exc_info=exc) return False