Skip to content

Commit da9006b

Browse files
ENGCOM-6064: Remove try-catch construction #1002
- Merge Pull Request magento/graphql-ce#1002 from TomashKhamlai/graphql-ce:coverage-downloadable-links-data-provider - Merged commits: 1. 7dc9e64 2. f45a672
2 parents ab19a3d + f45a672 commit da9006b

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ public function execute(array $cartItemData): array
4040

4141
if (isset($cartItemData['data']) && isset($cartItemData['data']['sku'])) {
4242
$sku = $cartItemData['data']['sku'];
43-
44-
try {
45-
$product = $this->productRepository->get($sku);
46-
} catch (NoSuchEntityException $e) {
47-
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
48-
}
43+
$product = $this->productRepository->get($sku);
4944

5045
if ($product->getLinksPurchasedSeparately() && isset($cartItemData['downloadable_product_links'])) {
5146
$downloadableLinks = $cartItemData['downloadable_product_links'];

dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ public function testAddNonExistentConfigurableProductVariationToCart()
265265

266266
$this->expectException(\Exception::class);
267267
$this->expectExceptionMessage(
268-
'Could not add the product with SKU configurable to the shopping cart: Could not find specified product.'
268+
'Could not add the product with SKU configurable to the shopping cart: The product that was requested ' .
269+
'doesn\'t exist. Verify the product and try again.'
269270
);
270271

271272
$this->graphQlMutation($query);

0 commit comments

Comments
 (0)