better error handling in google export, #12064
[freeside.git] / FS / FS / part_export / acct_google.pm
index c64d293..afc45db 100644 (file)
@@ -89,15 +89,18 @@ sub _export_unsuspend {
   );
 }
 
-sub captcha_url {
+sub auth_error {
   my $self = shift;
   my $google = $self->google_handle;
-  if (exists ($google->{'captcha_url'}) ) {
-    return 'http://www.google.com/accounts/'.$google->{'captcha_url'};
-  }
-  else {
-    return '';
+  if ( $google->{'error'} ) {
+    my $url = $google->{'captcha_url'} || '';
+    $url = "http://www.google.com/accounts/$url" if $url;
+    return { 'captcha_url' => $url,
+             'message'     => 
+               'Unable to connect to the Google API: '.$google->{'error'}.'.',
+           };
   }
+  return; #nothing on success
 }
 
 sub captcha_auth {