@@ -62,18 +62,20 @@ public function __construct(
62
62
* @param EnvelopeInterface[] $envelopes
63
63
* @return array
64
64
* @throws AMQPInvalidArgumentException
65
- * @throws \Exception
65
+ * @throws \LogicException
66
66
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
67
67
*/
68
68
public function beforeEnqueue (SubjectExchange $ subject , $ topic , array $ envelopes )
69
69
{
70
70
try {
71
71
$ storeId = $ this ->storeManager ->getStore ()->getId ();
72
72
} 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 ()
75
76
);
76
- throw new \Exception ($ e ->getMessage ());
77
+ $ this ->logger ->error ($ errorMessage );
78
+ throw new \LogicException ($ errorMessage );
77
79
}
78
80
79
81
$ updatedEnvelopes = [];
@@ -88,10 +90,9 @@ public function beforeEnqueue(SubjectExchange $subject, $topic, array $envelopes
88
90
try {
89
91
$ headers ->set ('store_id ' , $ storeId );
90
92
} 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 );
95
96
}
96
97
$ properties ['application_headers ' ] = $ headers ;
97
98
}
0 commit comments