Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Remove try-catch construction #1002

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ public function execute(array $cartItemData): array

if (isset($cartItemData['data']) && isset($cartItemData['data']['sku'])) {
$sku = $cartItemData['data']['sku'];

try {
$product = $this->productRepository->get($sku);
} catch (NoSuchEntityException $e) {
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
}
$product = $this->productRepository->get($sku);

if ($product->getLinksPurchasedSeparately() && isset($cartItemData['downloadable_product_links'])) {
$downloadableLinks = $cartItemData['downloadable_product_links'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ public function testAddNonExistentConfigurableProductVariationToCart()

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

$this->graphQlMutation($query);
Expand Down