Ensure we never return a null string from LookupCountry.
This commit is contained in:
@@ -237,14 +237,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
public static string LookupCountry(string ip)
|
public static string LookupCountry(string ip)
|
||||||
{
|
{
|
||||||
|
const string Unknown = "Unknown Location";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Game.GeoIpDatabase.Country(ip).Country.Name;
|
return Game.GeoIpDatabase.Country(ip).Country.Name ?? Unknown;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Write("geoip", "LookupCountry failed: {0}", e);
|
Log.Write("geoip", "LookupCountry failed: {0}", e);
|
||||||
return "Unknown Location";
|
return Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user