summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-12-22 17:03:07 -0800
committerMark Wells <mark@freeside.biz>2015-12-22 17:06:44 -0800
commitc8f4149f2dc5a1f593a6ba422181c3d433cc6ef7 (patch)
tree1133aaa1a6c7abb750583aaba890ccfbf06ad938 /FS/FS
parent3f7f6b5fa717facf9c63edc480071debfc02a33a (diff)
improve handling of internal errors from US Census geocoding, #39549
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/Misc/Geo.pm8
-rw-r--r--FS/FS/geocode_Mixin.pm2
-rw-r--r--FS/FS/log.pm2
-rw-r--r--FS/FS/log_context.pm1
4 files changed, 9 insertions, 4 deletions
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
}
}
diff --git a/FS/FS/geocode_Mixin.pm b/FS/FS/geocode_Mixin.pm
index 0625b5a..bc8c118 100644
--- a/FS/FS/geocode_Mixin.pm
+++ b/FS/FS/geocode_Mixin.pm
@@ -140,7 +140,7 @@ Returns the full country name.
sub country_full {
my $self = shift;
- $self->code2country($self->country);
+ $self->code2country($self->get('country'));
}
sub code2country {
diff --git a/FS/FS/log.pm b/FS/FS/log.pm
index 0c23b12..95bc4c4 100644
--- a/FS/FS/log.pm
+++ b/FS/FS/log.pm
@@ -148,7 +148,7 @@ sub check {
|| $self->ut_textn('tablename')
|| $self->ut_numbern('tablenum')
|| $self->ut_number('level')
- || $self->ut_text('message')
+ || $self->ut_anything('message')
;
return $error if $error;
diff --git a/FS/FS/log_context.pm b/FS/FS/log_context.pm
index ff34717..9dba582 100644
--- a/FS/FS/log_context.pm
+++ b/FS/FS/log_context.pm
@@ -10,6 +10,7 @@ my @contexts = ( qw(
FS::cust_main::Billing::bill_and_collect
FS::cust_main::Billing::bill
FS::pay_batch::import_from_gateway
+ FS::Misc::Geo::standardize_uscensus
Cron::bill
Cron::backup
Cron::upload