From 460d3f5606ce6e973a52fdc336f6a3d9b84c7a19 Mon Sep 17 00:00:00 2001 From: Rahul Tuli Date: Fri, 2 Jun 2023 16:25:04 -0400 Subject: [PATCH] [Cherry pick] Catch all exceptions for google analytics (#328) * Catch all exceptions * Update version to 1.5.1 --- src/sparsezoo/analytics.py | 7 +++---- src/sparsezoo/utils/gdpr.py | 3 +-- src/sparsezoo/version.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/sparsezoo/analytics.py b/src/sparsezoo/analytics.py index 6814b139..2cd138fa 100644 --- a/src/sparsezoo/analytics.py +++ b/src/sparsezoo/analytics.py @@ -21,7 +21,6 @@ import machineid import requests -from requests import HTTPError from sparsezoo.utils.gdpr import is_gdpr_country from sparsezoo.utils.helpers import disable_request_logs @@ -139,12 +138,12 @@ def _send_request(): body = response.content if _DEBUG: print(body) - except HTTPError as http_error: + except Exception as exception: if _DEBUG: - print(http_error) + print(exception) if raise_errors: - raise http_error + raise exception thread = threading.Thread(target=_send_request) thread.start() diff --git a/src/sparsezoo/utils/gdpr.py b/src/sparsezoo/utils/gdpr.py index 52a1ba5d..57c48f6a 100644 --- a/src/sparsezoo/utils/gdpr.py +++ b/src/sparsezoo/utils/gdpr.py @@ -17,7 +17,6 @@ import geocoder import requests -from requests import HTTPError from sparsezoo.utils.helpers import disable_request_logs @@ -79,7 +78,7 @@ def get_country_code() -> Optional[str]: geo = geocoder.ip(ip) return geo.country - except HTTPError: + except Exception: return None diff --git a/src/sparsezoo/version.py b/src/sparsezoo/version.py index 13550647..c0b1c435 100644 --- a/src/sparsezoo/version.py +++ b/src/sparsezoo/version.py @@ -20,7 +20,7 @@ from datetime import date -version_base = "1.5.0" +version_base = "1.5.1" is_release = False # change to True to set the generated version as a release version