Skip to content

Commit

Permalink
cs-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
y4roc authored Jul 12, 2024
1 parent 5c77f24 commit be97355
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/EventListener/MessengerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class MessengerListener
* @param bool $captureSoftFails Whether to capture errors thrown
* while processing a message that
* will be retried
* @param bool $captureMessageBody Add body of the message to the
* @param bool $captureMessageBody Add body of the message to the
* SentryException
*/
public function __construct(HubInterface $hub, bool $captureSoftFails = true, bool $captureMessageBody = true)
Expand Down Expand Up @@ -69,7 +69,7 @@ public function handleWorkerMessageFailedEvent(WorkerMessageFailedEvent $event):

$scope->setContext('messenger.body', [
'title' => 'CommandBus Message Body',
'body' => $this->castMessage($envelope->getMessage())
'body' => $this->castMessage($envelope->getMessage()),
]);

/** @var BusNameStamp|null $messageBusStamp */
Expand All @@ -87,20 +87,19 @@ public function handleWorkerMessageFailedEvent(WorkerMessageFailedEvent $event):

private function castMessage(object $message): mixed
{
if(!$this->captureMessageBody) {
if (!$this->captureMessageBody) {
return 'Capture message body is deactivated!';
}

try {
return json_decode(
json_encode($message, JSON_THROW_ON_ERROR),
json_encode($message, \JSON_THROW_ON_ERROR),
true,
512,
JSON_THROW_ON_ERROR
\JSON_THROW_ON_ERROR
);

} catch (\JsonException) {
return 'Error while parsing message body.';
return 'Error while parsing message body.';
}
}

Expand Down

0 comments on commit be97355

Please sign in to comment.