Skip to content

Commit 2c854be

Browse files
committed
Improve location error handling
1 parent 94bfeb9 commit 2c854be

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

yin_yang/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def defaults(self) -> dict:
326326
'running': False,
327327
'dark_mode': False,
328328
'mode': Modes.MANUAL.value,
329-
'coordinates': (0, 0),
329+
'coordinates': (0.0, 0.0),
330330
'update_location': False,
331331
'update_interval': 60,
332332
'times': ('07:00', '20:00'),

yin_yang/position.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ def get_qt_position() -> QGeoCoordinate:
5151

5252
def get_ipinfo_position() -> QGeoCoordinate:
5353
# use the old method as a fallback
54-
response = requests.get('https://www.ipinfo.io/loc')
54+
try:
55+
response = requests.get('https://www.ipinfo.io/loc')
56+
except Exception as e:
57+
logger.error(e)
58+
raise TypeError('Error while sending a request to get location')
59+
5560
if not response.ok:
56-
logger.error('Failed to get location from ipinfo.io')
61+
raise TypeError('Failed to get location from ipinfo.io')
5762

5863
loc_response = response.text.removesuffix('\n').split(',')
5964
loc: [float] = [float(coordinate) for coordinate in loc_response]

0 commit comments

Comments
 (0)