@@ -58,15 +58,16 @@ public function __construct(
58
58
* @param AddressInterface $address
59
59
* @param int|null $customerId Cart belongs to
60
60
* @return void
61
- * @throws \Magento\Framework\Exception\ NoSuchEntityException The specified customer ID or address ID is not valid.
61
+ * @throws NoSuchEntityException The specified customer ID or address ID is not valid.
62
62
*/
63
63
private function doValidate (AddressInterface $ address , $ customerId )
64
64
{
65
65
//validate customer id
66
66
if ($ customerId ) {
67
- $ customer = $ this ->customerRepository ->getById ($ customerId );
68
- if (!$ customer ->getId ()) {
69
- throw new \Magento \Framework \Exception \NoSuchEntityException (
67
+ try {
68
+ $ customer = $ this ->customerRepository ->getById ($ customerId );
69
+ } catch (NoSuchEntityException $ exception ) {
70
+ throw new NoSuchEntityException (
70
71
__ ('Invalid customer id %1 ' , $ customerId )
71
72
);
72
73
}
@@ -75,15 +76,15 @@ private function doValidate(AddressInterface $address, $customerId)
75
76
if ($ address ->getCustomerAddressId ()) {
76
77
//Existing address cannot belong to a guest
77
78
if (!$ customerId ) {
78
- throw new \ Magento \ Framework \ Exception \ NoSuchEntityException (
79
+ throw new NoSuchEntityException (
79
80
__ ('Invalid customer address id %1 ' , $ address ->getCustomerAddressId ())
80
81
);
81
82
}
82
83
//Validating address ID
83
84
try {
84
85
$ this ->addressRepository ->getById ($ address ->getCustomerAddressId ());
85
86
} catch (NoSuchEntityException $ e ) {
86
- throw new \ Magento \ Framework \ Exception \ NoSuchEntityException (
87
+ throw new NoSuchEntityException (
87
88
__ ('Invalid address id %1 ' , $ address ->getId ())
88
89
);
89
90
}
@@ -93,7 +94,7 @@ private function doValidate(AddressInterface $address, $customerId)
93
94
return $ address ->getId ();
94
95
}, $ this ->customerRepository ->getById ($ customerId )->getAddresses ());
95
96
if (!in_array ($ address ->getCustomerAddressId (), $ applicableAddressIds )) {
96
- throw new \ Magento \ Framework \ Exception \ NoSuchEntityException (
97
+ throw new NoSuchEntityException (
97
98
__ ('Invalid customer address id %1 ' , $ address ->getCustomerAddressId ())
98
99
);
99
100
}
@@ -105,7 +106,6 @@ private function doValidate(AddressInterface $address, $customerId)
105
106
*
106
107
* @param \Magento\Quote\Api\Data\AddressInterface $addressData The address data object.
107
108
* @return bool
108
- * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer ID or address ID is not valid.
109
109
*/
110
110
public function validate (AddressInterface $ addressData ): bool
111
111
{
@@ -120,7 +120,6 @@ public function validate(AddressInterface $addressData): bool
120
120
* @param CartInterface $cart
121
121
* @param AddressInterface $address
122
122
* @return void
123
- * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer ID or address ID is not valid.
124
123
*/
125
124
public function validateForCart (CartInterface $ cart , AddressInterface $ address )
126
125
{
0 commit comments