RT# 83401 Catch exception and display suitable error
authorMitch Jackson <mitch@freeside.biz>
Tue, 21 May 2019 17:42:16 +0000 (13:42 -0400)
committerMitch Jackson <mitch@freeside.biz>
Tue, 21 May 2019 20:12:36 +0000 (16:12 -0400)
httemplate/misc/process/payment.cgi

index 56bcfd8..5b18367 100644 (file)
@@ -186,15 +186,22 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
       %saveopt = map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}};
     }
 
-    my $error = $cust_main->save_cust_payby(
-      'saved_cust_payby' => \$cust_payby,
-      'payment_payby' => $payby,
-      'auto'          => scalar($cgi->param('auto')),
-      'weight'        => scalar($cgi->param('weight')),
-      'payinfo'       => $payinfo,
-      'payname'       => $payname,
-      %saveopt
-    );
+    my $error;
+    {
+      local $@;
+      eval {
+        $error = $cust_main->save_cust_payby(
+          'saved_cust_payby' => \$cust_payby,
+          'payment_payby' => $payby,
+          'auto'          => scalar($cgi->param('auto')),
+          'weight'        => scalar($cgi->param('weight')),
+          'payinfo'       => $payinfo,
+          'payname'       => $payname,
+          %saveopt
+        );
+      };
+      $error ||= $@;
+    }
 
     errorpage("error saving info, payment not processed: $error")
       if $error;