Skip to content

Commit 8fc86cd

Browse files
author
Yuri Kovsher
committed
Merge remote-tracking branch 'tango-ce/MAGETWO-33846' into MAGETWO-33812
2 parents 4a767c2 + 8018574 commit 8fc86cd

File tree

37 files changed

+104
-145
lines changed

37 files changed

+104
-145
lines changed

app/code/Magento/Backend/App/Action/Plugin/Authentication.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Backend\App\Action\Plugin;
87

8+
use Magento\Framework\Exception\AuthenticationException;
9+
910
class Authentication
1011
{
1112
/**
@@ -167,7 +168,7 @@ protected function _performLogin(\Magento\Framework\App\RequestInterface $reques
167168

168169
try {
169170
$this->_auth->login($username, $password);
170-
} catch (\Magento\Backend\Model\Auth\Exception $e) {
171+
} catch (AuthenticationException $e) {
171172
if (!$request->getParam('messageSent')) {
172173
$this->messageManager->addError($e->getMessage());
173174
$request->setParam('messageSent', true);

app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Backend\Controller\Adminhtml\System\Account;
87

8+
use Magento\Framework\Exception\AuthenticationException;
9+
910
class Save extends \Magento\Backend\Controller\Adminhtml\System\Account
1011
{
1112
/**
@@ -65,9 +66,7 @@ public function execute()
6566
$isCurrentUserPasswordValid = !empty($currentUserPassword) && is_string($currentUserPassword);
6667
try {
6768
if (!($isCurrentUserPasswordValid && $user->verifyIdentity($currentUserPassword))) {
68-
throw new \Magento\Backend\Model\Auth\Exception(
69-
__('You have entered an invalid password for current user.')
70-
);
69+
throw new AuthenticationException(__('You have entered an invalid password for current user.'));
7170
}
7271
if ($password !== '') {
7372
$user->setPassword($password);

app/code/Magento/Backend/Model/Auth.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Backend\Model;
77

8+
use Magento\Framework\Exception\AuthenticationException;
9+
use Magento\Framework\Exception\Plugin\AuthenticationException as PluginAuthenticationException;
10+
811
/**
912
* Backend Auth model
1013
*/
@@ -73,7 +76,7 @@ public function __construct(
7376
*
7477
* @param \Magento\Backend\Model\Auth\StorageInterface $storage
7578
* @return $this
76-
* @throw \Magento\Backend\Model\Auth\Exception if $storage is not correct
79+
* @throws \Magento\Framework\Exception\AuthenticationException
7780
*/
7881
public function setAuthStorage($storage)
7982
{
@@ -134,7 +137,7 @@ public function getCredentialStorage()
134137
* @param string $username
135138
* @param string $password
136139
* @return void
137-
* @throws \Exception|\Magento\Backend\Model\Auth\Plugin\Exception
140+
* @throws \Magento\Framework\Exception\AuthenticationException
138141
*/
139142
public function login($username, $password)
140143
{
@@ -158,7 +161,7 @@ public function login($username, $password)
158161
if (!$this->getAuthStorage()->getUser()) {
159162
self::throwException(__('Please correct the user name or password.'));
160163
}
161-
} catch (\Magento\Backend\Model\Auth\Plugin\Exception $e) {
164+
} catch (PluginAuthenticationException $e) {
162165
$this->_eventManager->dispatch(
163166
'backend_auth_user_login_failed',
164167
['user_name' => $username, 'exception' => $e]
@@ -198,14 +201,14 @@ public function isLoggedIn()
198201
*
199202
* @param string $msg
200203
* @return void
201-
* @throws \Magento\Backend\Model\Auth\Exception
204+
* @throws \Magento\Framework\Exception\AuthenticationException
202205
* @static
203206
*/
204207
public static function throwException($msg = null)
205208
{
206209
if (is_null($msg)) {
207210
$msg = __('Authentication error occurred.');
208211
}
209-
throw new \Magento\Backend\Model\Auth\Exception($msg);
212+
throw new AuthenticationException($msg);
210213
}
211214
}

app/code/Magento/Backend/Model/Auth/Exception.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/code/Magento/Backend/Model/Auth/Plugin/Exception.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/code/Magento/Captcha/Model/Observer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Captcha\Model;
77

8+
use Magento\Framework\Exception\Plugin\AuthenticationException as PluginAuthenticationException;
9+
810
/**
911
* Captcha Observer
1012
*
@@ -264,7 +266,7 @@ public function checkRegisterCheckout($observer)
264266
* Check Captcha On User Login Backend Page
265267
*
266268
* @param \Magento\Framework\Event\Observer $observer
267-
* @throws \Magento\Backend\Model\Auth\Plugin\Exception
269+
* @throws \Magento\Framework\Exception\Plugin\AuthenticationException
268270
* @return $this
269271
*/
270272
public function checkUserLoginBackend($observer)
@@ -275,7 +277,7 @@ public function checkUserLoginBackend($observer)
275277
if ($captchaModel->isRequired($login)) {
276278
if (!$captchaModel->isCorrect($this->_getCaptchaString($this->_request, $formId))) {
277279
$captchaModel->logAttempt($login);
278-
throw new \Magento\Backend\Model\Auth\Plugin\Exception(__('Incorrect CAPTCHA.'));
280+
throw new PluginAuthenticationException(__('Incorrect CAPTCHA.'));
279281
}
280282
}
281283
$captchaModel->logAttempt($login);

app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Checkout\Controller\Onepage;
87

8+
use Magento\Framework\Exception\PaymentException;
9+
910
class SaveOrder extends \Magento\Checkout\Controller\Onepage
1011
{
1112
/**
@@ -55,7 +56,7 @@ public function execute()
5556
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
5657
$result['success'] = true;
5758
$result['error'] = false;
58-
} catch (\Magento\Payment\Model\Info\Exception $e) {
59+
} catch (PaymentException $e) {
5960
$message = $e->getMessage();
6061
if (!empty($message)) {
6162
$result['error_messages'] = $message;

app/code/Magento/Cron/Exception.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/code/Magento/Cron/Model/Schedule.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Magento\Cron\Model;
88

9-
use Magento\Cron\Exception;
9+
use Magento\Framework\Exception\CronException;
1010

1111
/**
1212
* Crontab schedule model
@@ -80,13 +80,13 @@ public function _construct()
8080
/**
8181
* @param string $expr
8282
* @return $this
83-
* @throws Exception
83+
* @throws \Magento\Framework\Exception\CronException
8484
*/
8585
public function setCronExpr($expr)
8686
{
8787
$e = preg_split('#\s+#', $expr, null, PREG_SPLIT_NO_EMPTY);
8888
if (sizeof($e) < 5 || sizeof($e) > 6) {
89-
throw new Exception('Invalid cron expression: ' . $expr);
89+
throw new CronException(__('Invalid cron expression: %1', $expr));
9090
}
9191

9292
$this->setCronExprArr($e);
@@ -127,7 +127,7 @@ public function trySchedule()
127127
* @param string $expr
128128
* @param int $num
129129
* @return bool
130-
* @throws Exception
130+
* @throws \Magento\Framework\Exception\CronException
131131
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
132132
* @SuppressWarnings(PHPMD.NPathComplexity)
133133
*/
@@ -152,10 +152,10 @@ public function matchCronExpression($expr, $num)
152152
if (strpos($expr, '/') !== false) {
153153
$e = explode('/', $expr);
154154
if (sizeof($e) !== 2) {
155-
throw new Exception("Invalid cron expression, expecting 'match/modulus': " . $expr);
155+
throw new CronException(__('Invalid cron expression, expecting \'match/modulus\': %1', $expr));
156156
}
157157
if (!is_numeric($e[1])) {
158-
throw new Exception("Invalid cron expression, expecting numeric modulus: " . $expr);
158+
throw new CronException(__('Invalid cron expression, expecting numeric modulus: %1', $expr));
159159
}
160160
$expr = $e[0];
161161
$mod = $e[1];
@@ -171,7 +171,7 @@ public function matchCronExpression($expr, $num)
171171
// handle range
172172
$e = explode('-', $expr);
173173
if (sizeof($e) !== 2) {
174-
throw new Exception("Invalid cron expression, expecting 'from-to' structure: " . $expr);
174+
throw new CronException(__('Invalid cron expression, expecting \'from-to\' structure: %1', $expr));
175175
}
176176

177177
$from = $this->getNumeric($e[0]);
@@ -183,7 +183,7 @@ public function matchCronExpression($expr, $num)
183183
}
184184

185185
if ($from === false || $to === false) {
186-
throw new Exception("Invalid cron expression: " . $expr);
186+
throw new CronException(__('Invalid cron expression: %1', $expr));
187187
}
188188

189189
return $num >= $from && $num <= $to && $num % $mod === 0;

app/code/Magento/Directory/Model/Currency.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
namespace Magento\Directory\Model;
1313

14-
use Magento\Directory\Exception;
14+
use Magento\Framework\Exception\InputException;
1515
use Magento\Directory\Model\Currency\Filter;
1616

1717
/**
@@ -172,7 +172,7 @@ public function load($id, $field = null)
172172
*
173173
* @param string $toCurrency
174174
* @return float
175-
* @throws Exception
175+
* @throws \Magento\Framework\Exception\InputException
176176
*/
177177
public function getRate($toCurrency)
178178
{
@@ -181,7 +181,7 @@ public function getRate($toCurrency)
181181
} elseif ($toCurrency instanceof \Magento\Directory\Model\Currency) {
182182
$code = $toCurrency->getCurrencyCode();
183183
} else {
184-
throw new Exception(__('Please correct the target currency.'));
184+
throw new InputException(__('Please correct the target currency.'));
185185
}
186186
$rates = $this->getRates();
187187
if (!isset($rates[$code])) {
@@ -196,7 +196,7 @@ public function getRate($toCurrency)
196196
*
197197
* @param string $toCurrency
198198
* @return float
199-
* @throws Exception
199+
* @throws \Magento\Framework\Exception\InputException
200200
*/
201201
public function getAnyRate($toCurrency)
202202
{
@@ -205,7 +205,7 @@ public function getAnyRate($toCurrency)
205205
} elseif ($toCurrency instanceof \Magento\Directory\Model\Currency) {
206206
$code = $toCurrency->getCurrencyCode();
207207
} else {
208-
throw new Exception(__('Please correct the target currency.'));
208+
throw new InputException(__('Please correct the target currency.'));
209209
}
210210
$rates = $this->getRates();
211211
if (!isset($rates[$code])) {

0 commit comments

Comments
 (0)