From c7a4902af054f41113db62a4c872f053b0111b0d Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Mon, 19 Feb 2024 02:26:01 -0500 Subject: [PATCH] [F] Ignore geoip not found error --- src/main/java/icu/samnyan/aqua/net/utils/GeoIP.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/icu/samnyan/aqua/net/utils/GeoIP.kt b/src/main/java/icu/samnyan/aqua/net/utils/GeoIP.kt index 47bc5ca9..dfd300f1 100644 --- a/src/main/java/icu/samnyan/aqua/net/utils/GeoIP.kt +++ b/src/main/java/icu/samnyan/aqua/net/utils/GeoIP.kt @@ -1,6 +1,7 @@ package icu.samnyan.aqua.net.utils import com.maxmind.geoip2.DatabaseReader +import com.maxmind.geoip2.exception.AddressNotFoundException import ext.Bool import ext.Str import jakarta.annotation.PostConstruct @@ -78,7 +79,9 @@ class GeoIP( return try { val ipa = InetAddress.getByName(ip) geoLite.country(ipa)?.country?.isoCode ?: "" - } catch (e: Exception) { + } + catch (e: AddressNotFoundException) { "" } + catch (e: Exception) { log.error("Failed to get country from IP $ip", e) "" }