summaryrefslogtreecommitdiff
path: root/iss
diff options
context:
space:
mode:
Diffstat (limited to 'iss')
-rw-r--r--iss/geo.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/iss/geo.py b/iss/geo.py
index 5413913..50aec0c 100644
--- a/iss/geo.py
+++ b/iss/geo.py
@@ -16,9 +16,12 @@ default_location = namedtuple("Location", DEFAULT_LOCATION.keys())(
def get_location(ip):
- with geoip2.database.Reader(GEOIP_GEOLITE2_CITY_PATH) as reader:
- try:
- res = reader.city(ip)
- return res.location
- except geoip2.errors.AddressNotFoundError:
- return default_location
+ try:
+ with geoip2.database.Reader(GEOIP_GEOLITE2_CITY_PATH) as reader:
+ try:
+ res = reader.city(ip)
+ return res.location
+ except geoip2.errors.AddressNotFoundError:
+ return default_location
+ except TypeError:
+ return default_location