From 0f4fd4a1b6cf8bcd94407c682b89bbcd189766ef Mon Sep 17 00:00:00 2001 From: Apeksha Hegde Date: Fri, 20 Jan 2023 22:56:40 +0530 Subject: [PATCH 1/2] Handling connection error for socrata API --- retriever/lib/socrata.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/retriever/lib/socrata.py b/retriever/lib/socrata.py index 2fdb85508..cc7ddc3b9 100644 --- a/retriever/lib/socrata.py +++ b/retriever/lib/socrata.py @@ -41,8 +41,8 @@ def socrata_autocomplete_search(dataset): for i in range(len(datasets["results"])): names.append(datasets["results"][i]["title"]) - except HTTPError as e: - print("HTTPError :", e) + except (HTTPError,requests.exceptions.ConnectionError) as e: + print("Error Occured :", e) return None return names @@ -77,8 +77,8 @@ def socrata_dataset_info(dataset_name): "link": result[i]["link"] }) - except HTTPError as e: - print("HTTPError : ", e) + except (HTTPError,requests.exceptions.ConnectionError) as e: + print("Error Occured :", e) return None return resources @@ -129,8 +129,8 @@ def find_socrata_dataset_by_id(dataset_id): print("No socrata dataset exists for the id : {dataset_id}".format( dataset_id=dataset_id)) - except HTTPError as e: - print("HTTPError : ", e) + except (HTTPError,requests.exceptions.ConnectionError) as e: + print("Error Occured :", e) return {} return resource From ae4db496f0cd52c6742e818ce96ba4bb6c17d067 Mon Sep 17 00:00:00 2001 From: Apeksha Hegde Date: Sat, 21 Jan 2023 01:05:28 +0530 Subject: [PATCH 2/2] space added for handling connection error --- retriever/lib/socrata.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/retriever/lib/socrata.py b/retriever/lib/socrata.py index cc7ddc3b9..c3182dac4 100644 --- a/retriever/lib/socrata.py +++ b/retriever/lib/socrata.py @@ -41,8 +41,8 @@ def socrata_autocomplete_search(dataset): for i in range(len(datasets["results"])): names.append(datasets["results"][i]["title"]) - except (HTTPError,requests.exceptions.ConnectionError) as e: - print("Error Occured :", e) + except (HTTPError, requests.exceptions.ConnectionError) as e: + print("Error Occured: ", e) return None return names @@ -77,8 +77,8 @@ def socrata_dataset_info(dataset_name): "link": result[i]["link"] }) - except (HTTPError,requests.exceptions.ConnectionError) as e: - print("Error Occured :", e) + except (HTTPError, requests.exceptions.ConnectionError) as e: + print("Error Occured: ", e) return None return resources @@ -129,8 +129,8 @@ def find_socrata_dataset_by_id(dataset_id): print("No socrata dataset exists for the id : {dataset_id}".format( dataset_id=dataset_id)) - except (HTTPError,requests.exceptions.ConnectionError) as e: - print("Error Occured :", e) + except (HTTPError, requests.exceptions.ConnectionError) as e: + print("Error Occured: ", e) return {} return resource