Skip to content

Commit 8018574

Browse files
author
Yuri Kovsher
committed
MAGETWO-33846: Replace obsolete exceptions (see description - Part1)
1 parent 6384473 commit 8018574

File tree

13 files changed

+19
-26
lines changed

13 files changed

+19
-26
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Backend\Model;
77

88
use Magento\Framework\Exception\AuthenticationException;
9+
use Magento\Framework\Exception\Plugin\AuthenticationException as PluginAuthenticationException;
910

1011
/**
1112
* Backend Auth model
@@ -75,7 +76,7 @@ public function __construct(
7576
*
7677
* @param \Magento\Backend\Model\Auth\StorageInterface $storage
7778
* @return $this
78-
* @throws \Magento\Framework\Exception\AuthenticationException if $storage is not correct
79+
* @throws \Magento\Framework\Exception\AuthenticationException
7980
*/
8081
public function setAuthStorage($storage)
8182
{
@@ -136,7 +137,7 @@ public function getCredentialStorage()
136137
* @param string $username
137138
* @param string $password
138139
* @return void
139-
* @throws \Exception|\Magento\Framework\Exception\Plugin\AuthenticationException
140+
* @throws \Magento\Framework\Exception\AuthenticationException
140141
*/
141142
public function login($username, $password)
142143
{
@@ -160,7 +161,7 @@ public function login($username, $password)
160161
if (!$this->getAuthStorage()->getUser()) {
161162
self::throwException(__('Please correct the user name or password.'));
162163
}
163-
} catch (\Magento\Framework\Exception\Plugin\AuthenticationException $e) {
164+
} catch (PluginAuthenticationException $e) {
164165
$this->_eventManager->dispatch(
165166
'backend_auth_user_login_failed',
166167
['user_name' => $username, 'exception' => $e]

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

Lines changed: 3 additions & 1 deletion
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
*
@@ -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\Framework\Exception\Plugin\AuthenticationException(__('Incorrect CAPTCHA.'));
280+
throw new PluginAuthenticationException(__('Incorrect CAPTCHA.'));
279281
}
280282
}
281283
$captchaModel->logAttempt($login);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ public function _construct()
8080
/**
8181
* @param string $expr
8282
* @return $this
83-
* @throws CronException
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 CronException('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 CronException
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 CronException('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 CronException('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 CronException('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 CronException('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/Integration/Service/V1/Integration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function _checkIntegrationByName($name)
129129
{
130130
$integration = $this->_integrationFactory->create()->load($name, 'name');
131131
if ($integration->getId()) {
132-
throw new IntegrationException(__("Integration with name '%1' exists.", $name));
132+
throw new IntegrationException(__('Integration with name \'%1\' exists.', $name));
133133
}
134134
}
135135

@@ -144,7 +144,7 @@ protected function _loadIntegrationById($integrationId)
144144
{
145145
$integration = $this->_integrationFactory->create()->load($integrationId);
146146
if (!$integration->getId()) {
147-
throw new IntegrationException(__("Integration with ID '%1' does not exist.", $integrationId));
147+
throw new IntegrationException(__('Integration with ID \'%1\' does not exist.', $integrationId));
148148
}
149149
return $integration;
150150
}

app/code/Magento/Integration/Service/V1/IntegrationInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function update(array $integrationData);
6868
*
6969
* @param int $integrationId
7070
* @return array Integration data
71-
* @throws \Magento\Framework\Exception\IntegrationException If the integration does not exist or cannot be deleted
71+
* @throws \Magento\Framework\Exception\IntegrationException
7272
*/
7373
public function delete($integrationId);
7474
}

app/code/Magento/Integration/Service/V1/Oauth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ protected function _loadConsumerById($consumerId)
265265
{
266266
$consumer = $this->_consumerFactory->create()->load($consumerId);
267267
if (!$consumer->getId()) {
268-
throw new IntegrationException(__("Consumer with ID '%1' does not exist.", $consumerId));
268+
throw new IntegrationException(__('Consumer with ID \'%1\' does not exist.', $consumerId));
269269
}
270270
return $consumer;
271271
}

app/code/Magento/User/Controller/Adminhtml/User/Save.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ public function execute()
5656
&& !empty($data[$currentUserPasswordField]) && is_string($data[$currentUserPasswordField]);
5757
try {
5858
if (!($isCurrentUserPasswordValid && $currentUser->verifyIdentity($data[$currentUserPasswordField]))) {
59-
throw new AuthenticationException(
60-
__('You have entered an invalid password for current user.')
61-
);
59+
throw new AuthenticationException(__('You have entered an invalid password for current user.'));
6260
}
6361
$model->save();
6462
$this->messageManager->addSuccess(__('You saved the user.'));

app/code/Magento/User/Model/User.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,6 @@ public function getAclRole()
540540
* @param string $password
541541
* @return bool
542542
* @throws \Magento\Framework\Exception\LocalizedException
543-
* @throws \Magento\Framework\Exception\AuthenticationException
544-
* @throws \Magento\Framework\Exception\Plugin\AuthenticationException
545543
*/
546544
public function authenticate($username, $password)
547545
{

dev/tests/unit/testsuite/Magento/Cron/Model/ScheduleTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* @category Magento
4-
* @package Magento_Cron
53
* Copyright © 2015 Magento. All rights reserved.
64
* See COPYING.txt for license details.
75
*/

0 commit comments

Comments
 (0)