replace \Exception with\ Box_Exception or \Payment_Exception

More exception messages can be translated.
\Payment_Exception constructor uses gettext __() for translation.

issue #262
This commit is contained in:
Vaidas Lungis committed 2015-02-17 12:39:59 +02:00
1 parent 286d085d35
commit 9047b1cd7d
14 files changed
+39 -24

No files matched your search

+1 -1
View File
@@ -69,7 +69,7 @@ class Api_Abstract implements InjectionAwareInterface
public function getMod()
{
if(!$this->mod) {
throw new Exception('Mod object is not set for the service');
throw new Box_Exception('Mod object is not set for the service');
}
return $this->mod;
}
+1 -1
View File
@@ -18,7 +18,7 @@ class Box_Crypt implements \Box\InjectionAwareInterface
function __construct()
{
if (!extension_loaded('mcrypt')) {
throw new Exception('php mcrypt extension must be enabled on your server');
throw new Box_Exception('php mcrypt extension must be enabled on your server');
}
}
+1 -1
View File
@@ -88,7 +88,7 @@ class Model_ProductTable implements \Box\InjectionAwareInterface
break;
default:
throw new Exception('Unknown period selected ' . $code);
throw new Box_Exception('Unknown period selected ' . $code);
break;
}
}
+1 -1
View File
@@ -201,7 +201,7 @@ To find your ACCOUNT ID and SECRET KEY:
public function processTransaction($api_admin, $id, $data, $gateway_id)
{
if(APPLICATION_ENV != 'testing' && !$this->_isIpnValid($data)) {
throw new Exception('IPN is not valid');
throw new Payment_Exception('IPN is not valid');
}
$ipn = $data['get'];
@@ -179,7 +179,7 @@ class Payment_Adapter_Interkassa extends Payment_AdapterAbstract implements \Box
public function processTransaction($api_admin, $id, $data, $gateway_id)
{
if(!$this->isIpnValid($data)) {
throw new Exception('IPN is not valid');
throw new Payment_Exception('IPN is not valid');
}
$ipn = $data['post'];
@@ -31,11 +31,11 @@ class Payment_Adapter_PayPalEmail implements \Box\InjectionAwareInterface
$this->config = $config;
if(!function_exists('curl_exec')) {
throw new Exception('PHP Curl extension must be enabled in order to use PayPal gateway');
throw new Payment_Exception('PHP Curl extension must be enabled in order to use PayPal gateway');
}
if(!$this->config['email']) {
throw new Exception('Payment gateway "PayPal" is not configured properly. Please update configuration parameter "PayPal Email address" at "Configuration -> Payments".');
throw new Payment_Exception('Payment gateway "PayPal" is not configured properly. Please update configuration parameter "PayPal Email address" at "Configuration -> Payments".');
}
}
@@ -147,7 +147,7 @@ class Payment_Adapter_PayPalEmail implements \Box\InjectionAwareInterface
public function processTransaction($api_admin, $id, $data, $gateway_id)
{
if(APPLICATION_ENV != 'testing' && !$this->_isIpnValid($data)) {
throw new Exception('IPN is not valid');
throw new Payment_Exception('IPN is not valid');
}
$ipn = $data['post'];
+2 -2
View File
@@ -19,11 +19,11 @@ class Payment_Adapter_Payza extends Payment_AdapterAbstract
$this->config = $config;
if(!function_exists('curl_exec')) {
throw new Exception('PHP Curl extension must be enabled in order to use Payza gateway');
throw new Payment_Exception('PHP Curl extension must be enabled in order to use Payza gateway');
}
if(!$this->config['email']) {
throw new Exception('Payment gateway "Payza" is not configured properly. Please update configuration parameter "Payza Email address" at "Configuration -> Payments".');
throw new Payment_Exception('Payment gateway "Payza" is not configured properly. Please update configuration parameter "Payza Email address" at "Configuration -> Payments".');
}
}
@@ -116,7 +116,7 @@ class Payment_Adapter_TwoCheckout implements \Box\InjectionAwareInterface
$ipn = array_merge($data['get'], $data['post']);
if(APPLICATION_ENV != 'testing' && !$this->_isIpnValid($ipn)) {
throw new Exception('2Checkout IPN is not valid');
throw new Payment_Exception('2Checkout IPN is not valid');
}
if($ipn['message_type'] == 'ORDER_CREATED') {
@@ -172,7 +172,7 @@ class Payment_Adapter_TwoCheckout implements \Box\InjectionAwareInterface
}
if(!$invoice_id) {
throw new Exception('Invoice id could not be determined for this transaction');
throw new Payment_Exception('Invoice id could not be determined for this transaction');
}
$invoice = $api_admin->invoice_get(array('id'=>$invoice_id));
+1 -1
View File
@@ -104,7 +104,7 @@ class Payment_Adapter_WebMoney implements \Box\InjectionAwareInterface
public function processTransaction($api_admin, $id, $data, $gateway_id)
{
if(APPLICATION_ENV != 'testing' && !$this->isIpnValid($data)) {
throw new Exception('WebMoney IPN is not valid');
throw new Payment_Exception('WebMoney IPN is not valid');
}
$ipn = $data['post'];
+17 -1
View File
@@ -11,4 +11,20 @@
*/
class Payment_Exception extends Exception
{}
{
/**
* Creates a new translated exception.
*
* @param string error message
* @param array translation variables
* @return Exception|null
*/
public function __construct($message, array $variables = NULL, $code = 0)
{
// Set the message
$message = __($message, $variables);
// Pass the message to the parent
parent::__construct($message, $code);
}
}
+2 -2
View File
@@ -467,14 +467,14 @@ class Whois {
// If tldname have not been found
if($whois_server == "") {
throw new Exception('No whois server for this tld in list!');
throw new Box_Exception('No whois server for this tld in list!');
}
// Getting whois information
$fp = @fsockopen($whois_server,43);
if (!$fp) {
throw new Exception('Whois server '. $whois_server .' is not available');
throw new Box_Exception('Whois server '. $whois_server .' is not available');
}
$dom=$domainname.".".$tldname;
+2 -2
View File
@@ -534,14 +534,14 @@ class Whois2 {
// If tldname have not been found
if($whois_server == "") {
throw new Exception('No whois server for this tld in list!');
throw new Box_Exception('No whois server for this tld in list!');
}
// Getting whois information
$fp = @fsockopen($whois_server,43);
if (!$fp) {
throw new Exception('Whois server '. $whois_server .' is not available');
throw new Box_Exception('Whois server '. $whois_server .' is not available');
}
$dom=$domainname.".".$tldname;
@@ -81,8 +81,8 @@ class akismet {
if($api_key) {
$this->api_key = $api_key;
} else {
throw new Exception('Akismet API Key not set.');
$this->error = true;
throw new Exception(__('Akismet API Key not set.'));
}
//If no site URL was given
@@ -124,7 +124,7 @@ class akismet {
if(!is_resource($this->connection_handle)) {
//Try to create one
if(!$this->connection_handle = curl_init()) {
throw new Exception('Could not start new CURL instance');
throw new Exception(__('Could not start new CURL instance'));
$this->error = true;
return;
}
@@ -161,9 +161,8 @@ class akismet {
if(is_resource($this->connection_handle)) {
//Try to close it
if(!curl_close($this->connection_handle)) {
throw new Exception('Could not close the CURL instance');
$this->error = true;
return;
throw new Exception(__('Could not close the CURL instance'));
}
}
return true;
@@ -188,8 +187,8 @@ class akismet {
//Send Data and grab the result
if(!$response = curl_exec($this->connection_handle)) {
throw new Exception('Could not send cURL request');
$this->error = true;
throw new Exception(__('Could not send cURL request'));
return;
}
+1 -1
View File
@@ -78,7 +78,7 @@ function _recaptcha_http_post($host, $path, $data, $port = 80) {
$response = '';
if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
throw new Exception('Could not open socket');
throw new Exception(__('Could not open socket'));
}
fwrite($fs, $http_request);