Skip to content

Commit e9831be

Browse files
author
Dmytro Poperechnyy
committed
MAGETWO-33814: Change parent class of Model\Exception sub-classes to Localized
- Added new Magento\Framework\Exception\Customer\Exception; - Eliminated check by error code from AccountManagement class;
1 parent 8cb77e4 commit e9831be

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Magento\Framework\Exception\EmailNotConfirmedException;
2525
use Magento\Framework\Exception\InputException;
2626
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
27+
use Magento\Framework\Exception\LocalizedException;
2728
use Magento\Framework\Exception\NoSuchEntityException;
2829
use Magento\Framework\Exception\State\ExpiredException;
2930
use Magento\Framework\Exception\State\InputMismatchException;
@@ -511,10 +512,9 @@ public function createAccountWithPasswordHash(
511512
try {
512513
// If customer exists existing hash will be used by Repository
513514
$customer = $this->customerRepository->save($customer, $hash);
514-
} catch (\Magento\Customer\Exception $e) {
515-
if ($e->getCode() === CustomerModel::EXCEPTION_EMAIL_EXISTS) {
516-
throw new InputMismatchException('Customer with the same email already exists in associated website.');
517-
}
515+
} catch (\Magento\Framework\Exception\Customer\Exception $e) {
516+
throw new InputMismatchException('Customer with the same email already exists in associated website.');
517+
} catch (LocalizedException $e) {
518518
throw $e;
519519
}
520520

app/code/Magento/Customer/Model/Resource/Customer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function _getDefaultAttributes()
9393
* @param \Magento\Framework\Object $customer
9494
* @return $this
9595
* @throws \Magento\Customer\Exception
96-
* @throws \Magento\Framework\Exception\LocalizedException
96+
* @throws \Magento\Framework\Model\Exception
9797
*/
9898
protected function _beforeSave(\Magento\Framework\Object $customer)
9999
{

dev/tests/integration/testsuite/Magento/Tax/Model/TaxClass/RepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function testSave()
6666

6767
/**
6868
* @magentoDbIsolation enabled
69-
* @expectedException \Magento\Framework\Exception\InputException
70-
* @expectedExceptionMessage A class with the same name already exists for ClassType PRODUCT.
69+
* @expectedException \Magento\Framework\Exception\AlreadyExistsException
70+
* @expectedExceptionMessage Class name and class type already exists.
7171
*/
7272
public function testSaveThrowsExceptionIfGivenTaxClassNameIsNotUnique()
7373
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Exception\Customer;
7+
8+
use Magento\Framework\Exception\LocalizedException;
9+
10+
class Exception extends LocalizedException
11+
{
12+
}

0 commit comments

Comments
 (0)