Skip to content

Commit

Permalink
Improve handling for geoplgin.net being unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Sep 20, 2018
1 parent 8e6d265 commit 8c27542
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/CGI/Lingua.pm
Expand Up @@ -962,8 +962,9 @@ sub country {
LWP::Simple->import();
JSON::Parse->import();

my $data = JSON::Parse::parse_json(LWP::Simple::get("http://www.geoplugin.net/json.gp?ip=$ip"));
$self->{_country} = $data->{'geoplugin_countryCode'};
if(my $data = LWP::Simple::get("http://www.geoplugin.net/json.gp?ip=$ip")) {
$self->{_country} = JSON::Parse::parse_json($data)->{'geoplugin_countryCode'};
}
}
}
unless($self->{_country}) {
Expand Down

0 comments on commit 8c27542

Please sign in to comment.