Skip to content

Commit 460d3f5

Browse files
authored
[Cherry pick] Catch all exceptions for google analytics (#328)
* Catch all exceptions * Update version to 1.5.1
1 parent e0992c6 commit 460d3f5

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/sparsezoo/analytics.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import machineid
2323
import requests
24-
from requests import HTTPError
2524

2625
from sparsezoo.utils.gdpr import is_gdpr_country
2726
from sparsezoo.utils.helpers import disable_request_logs
@@ -139,12 +138,12 @@ def _send_request():
139138
body = response.content
140139
if _DEBUG:
141140
print(body)
142-
except HTTPError as http_error:
141+
except Exception as exception:
143142
if _DEBUG:
144-
print(http_error)
143+
print(exception)
145144

146145
if raise_errors:
147-
raise http_error
146+
raise exception
148147

149148
thread = threading.Thread(target=_send_request)
150149
thread.start()

src/sparsezoo/utils/gdpr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import geocoder
1919
import requests
20-
from requests import HTTPError
2120

2221
from sparsezoo.utils.helpers import disable_request_logs
2322

@@ -79,7 +78,7 @@ def get_country_code() -> Optional[str]:
7978
geo = geocoder.ip(ip)
8079

8180
return geo.country
82-
except HTTPError:
81+
except Exception:
8382
return None
8483

8584

src/sparsezoo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from datetime import date
2121

2222

23-
version_base = "1.5.0"
23+
version_base = "1.5.1"
2424
is_release = False # change to True to set the generated version as a release version
2525

2626

0 commit comments

Comments
 (0)