From 7b90424db790634149932f49e253e4b33f8186a5 Mon Sep 17 00:00:00 2001 From: Mitch Jackson Date: Tue, 21 May 2019 13:42:16 -0400 Subject: [PATCH] RT# 83401 Catch exception and display suitable error --- httemplate/misc/process/payment.cgi | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index 56bcfd872..5b18367f7 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -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; -- 2.11.0