From c8f4149f2dc5a1f593a6ba422181c3d433cc6ef7 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 22 Dec 2015 17:03:07 -0800 Subject: improve handling of internal errors from US Census geocoding, #39549 --- FS/FS/Misc/Geo.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'FS/FS/Misc') diff --git a/FS/FS/Misc/Geo.pm b/FS/FS/Misc/Geo.pm index e83d6dc..aa4e55e 100644 --- a/FS/FS/Misc/Geo.pm +++ b/FS/FS/Misc/Geo.pm @@ -11,6 +11,7 @@ use Cpanel::JSON::XS; use URI::Escape 3.31; use Data::Dumper; use FS::Conf; +use FS::Log; use Locale::Country; FS::UID->install_callback( sub { @@ -300,6 +301,8 @@ sub standardize_usps { sub standardize_uscensus { my $self = shift; my $location = shift; + my $log = FS::Log->new('FS::Misc::Geo::standardize_uscensus'); + $log->debug(join("\n", @{$location}{'address1', 'city', 'state', 'zip'})); eval "use Geo::USCensus::Geocoding"; die $@ if $@; @@ -322,6 +325,7 @@ sub standardize_uscensus { my $result = Geo::USCensus::Geocoding->query($request); if ( $result->is_match ) { # unfortunately we get the address back as a single line + $log->debug($result->address); if ($result->address =~ /^(.*), (.*), ([A-Z]{2}), (\d{5}.*)$/) { return +{ address1 => $1, @@ -341,8 +345,8 @@ sub standardize_uscensus { } elsif ( $result->match_level ) { die "Geocoding did not find a matching address.\n"; } else { - warn Dumper($result) if $DEBUG; - die $result->error_message; + $log->error($result->error_message); + return; # for internal errors, don't return anything } } -- cgit v1.1