Skip to content

Commit

Permalink
fix exception type and message
Browse files Browse the repository at this point in the history
  • Loading branch information
anvasiliev committed May 31, 2019
1 parent fb06c33 commit 06bc3a2
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ 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)
{
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 = [];
Expand All @@ -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;
}
Expand Down

0 comments on commit 06bc3a2

Please sign in to comment.