diff --git a/app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php b/app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php index ae8ff6948fc42..9a8f92e5696df 100644 --- a/app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php +++ b/app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php @@ -62,7 +62,7 @@ public function __construct( * @param EnvelopeInterface[] $envelopes * @return array * @throws AMQPInvalidArgumentException - * @throws \Exception + * @throws \LogicException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes) @@ -70,10 +70,12 @@ public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes try { $storeId = $this->storeManager->getStore()->getId(); } catch (NoSuchEntityException $e) { - $this->logger->error( - sprintf("Can't get current storeId and inject to amqp message. Error %s.", $e->getMessage()) + $errorMessage = sprintf( + "Can't get current storeId and inject to amqp message. Error %s.", + $e->getMessage() ); - throw new \Exception($e->getMessage()); + $this->logger->error($errorMessage); + throw new \LogicException($errorMessage); } $updatedEnvelopes = []; @@ -88,10 +90,9 @@ public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes try { $headers->set('store_id', $storeId); } catch (AMQPInvalidArgumentException $ea) { - $this->logger->error( - sprintf("Can't set storeId to amqp message. Error %s.", $ea->getMessage()) - ); - throw new AMQPInvalidArgumentException($ea->getMessage()); + $errorMessage = sprintf("Can't set storeId to amqp message. Error %s.", $ea->getMessage()); + $this->logger->error($errorMessage); + throw new AMQPInvalidArgumentException($errorMessage); } $properties['application_headers'] = $headers; }