Handle census site unavailability w/o throwing.
authorScott Gasch <[email protected]>
Fri, 29 Apr 2022 18:26:25 +0000 (11:26 -0700)
committerScott Gasch <[email protected]>
Fri, 29 Apr 2022 18:26:25 +0000 (11:26 -0700)
geocode.py

index 0a020d5fd79fa0145f3a944dacafcb12f4d0470e..428eb58ccb793f6cf4508aca16b5d4c202a45257 100644 (file)
@@ -35,7 +35,12 @@ def geocode_address(address: str) -> Optional[Dict[str, Any]]:
     url += '&layers=all&benchmark=4&vintage=4'
     url = requote_uri(url)
     logger.debug('GET: %s', url)
-    r = requests.get(url)
+    try:
+        r = requests.get(url)
+    except Exception as e:
+        logger.exception(e)
+        return None
+
     if r.status_code != 200:
         logger.error('Unexpected response code %d, wanted 200.  Fail.', r.status_code)
         return None