From a3691ed99b297ab9dc1ecf723cd245d03426d535 Mon Sep 17 00:00:00 2001 From: Hillel Arnold Date: Tue, 6 Oct 2026 15:12:21 -0400 Subject: [PATCH 1/2] handle generic fetch errors --- src/mappings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mappings.py b/src/mappings.py index 3bf460a..f2ce819 100644 --- a/src/mappings.py +++ b/src/mappings.py @@ -68,8 +68,11 @@ def convert_dates(value): def has_online_asset(identifier, config): if not config.get('ASSET_BASEURL'): return False - req = requests.head(f"{config['ASSET_BASEURL'].rstrip('/')}/pdfs/{identifier}") - return req.status_code == 200 + try: + req = requests.head(f"{config['ASSET_BASEURL'].rstrip('/')}/pdfs/{identifier}") + return req.status_code == 200 + except Exception: + return False def has_online_instance(instances, uri, config): From 5a9181c061b57d1a046b94c819fd0ed98498d604 Mon Sep 17 00:00:00 2001 From: Hillel Arnold Date: Tue, 6 Oct 2026 15:15:44 -0400 Subject: [PATCH 2/2] add logging --- src/mappings.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mappings.py b/src/mappings.py index f2ce819..6c00b84 100644 --- a/src/mappings.py +++ b/src/mappings.py @@ -1,6 +1,8 @@ import json +import logging import re import xml.etree.ElementTree as ET +from os import getenv import odin import pycountry @@ -19,6 +21,9 @@ SourceRef, SourceResource, SourceStructuredDate, SourceSubject) +logger = logging.getLogger() +logger.setLevel(getenv('LOGGING_LEVEL', logging.INFO)) + def identifier_from_uri(uri): """Creates a short UUID. @@ -71,7 +76,8 @@ def has_online_asset(identifier, config): try: req = requests.head(f"{config['ASSET_BASEURL'].rstrip('/')}/pdfs/{identifier}") return req.status_code == 200 - except Exception: + except Exception as e: + logging.info(e) return False