7
7
8
8
namespace Magento \CustomerGraphQl \Model \Customer ;
9
9
10
+ use Magento \Framework \Exception \NoSuchEntityException ;
10
11
use Magento \Framework \GraphQl \Exception \GraphQlAlreadyExistsException ;
11
12
use Magento \Framework \GraphQl \Exception \GraphQlAuthenticationException ;
12
13
use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
14
+ use Magento \Framework \GraphQl \Exception \GraphQlNoSuchEntityException ;
13
15
use Magento \Store \Model \StoreManagerInterface ;
14
16
use Magento \Customer \Api \Data \CustomerInterface ;
15
17
use Magento \Framework \Api \DataObjectHelper ;
@@ -89,8 +91,7 @@ public function __construct(
89
91
* @throws GraphQlAlreadyExistsException
90
92
* @throws GraphQlAuthenticationException
91
93
* @throws GraphQlInputException
92
- * @throws \Magento\Framework\Exception\NoSuchEntityException
93
- * @throws \Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException
94
+ * @throws GraphQlNoSuchEntityException
94
95
*/
95
96
public function execute (CustomerInterface $ customer , array $ data ): void
96
97
{
@@ -106,7 +107,12 @@ public function execute(CustomerInterface $customer, array $data): void
106
107
$ filteredData = array_diff_key ($ data , array_flip ($ this ->restrictedKeys ));
107
108
$ this ->dataObjectHelper ->populateWithArray ($ customer , $ filteredData , CustomerInterface::class);
108
109
109
- $ customer ->setStoreId ($ this ->storeManager ->getStore ()->getId ());
110
+ try {
111
+ $ customer ->setStoreId ($ this ->storeManager ->getStore ()->getId ());
112
+ } catch (NoSuchEntityException $ exception ) {
113
+ throw new GraphQlNoSuchEntityException (__ ($ exception ->getMessage ()), $ exception );
114
+ }
115
+
110
116
111
117
$ this ->saveCustomer ->execute ($ customer );
112
118
0 commit comments