Skip to content

Commit 06bc3a2

Browse files
committed
fix exception type and message
1 parent fb06c33 commit 06bc3a2

File tree

1 file changed

+9
-8
lines changed
  • app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk

1 file changed

+9
-8
lines changed

app/code/Magento/AmqpStore/Plugin/Framework/Amqp/Bulk/Exchange.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,20 @@ public function __construct(
6262
* @param EnvelopeInterface[] $envelopes
6363
* @return array
6464
* @throws AMQPInvalidArgumentException
65-
* @throws \Exception
65+
* @throws \LogicException
6666
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6767
*/
6868
public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes)
6969
{
7070
try {
7171
$storeId = $this->storeManager->getStore()->getId();
7272
} catch (NoSuchEntityException $e) {
73-
$this->logger->error(
74-
sprintf("Can't get current storeId and inject to amqp message. Error %s.", $e->getMessage())
73+
$errorMessage = sprintf(
74+
"Can't get current storeId and inject to amqp message. Error %s.",
75+
$e->getMessage()
7576
);
76-
throw new \Exception($e->getMessage());
77+
$this->logger->error($errorMessage);
78+
throw new \LogicException($errorMessage);
7779
}
7880

7981
$updatedEnvelopes = [];
@@ -88,10 +90,9 @@ public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes
8890
try {
8991
$headers->set('store_id', $storeId);
9092
} catch (AMQPInvalidArgumentException $ea) {
91-
$this->logger->error(
92-
sprintf("Can't set storeId to amqp message. Error %s.", $ea->getMessage())
93-
);
94-
throw new AMQPInvalidArgumentException($ea->getMessage());
93+
$errorMessage = sprintf("Can't set storeId to amqp message. Error %s.", $ea->getMessage());
94+
$this->logger->error($errorMessage);
95+
throw new AMQPInvalidArgumentException($errorMessage);
9596
}
9697
$properties['application_headers'] = $headers;
9798
}

0 commit comments

Comments
 (0)