use Symfony\Component\Messenger\Stamp\ErrorDetailsStamp;
final class AddErrorDetailsStampListener implements EventSubscriberInterface
{ public function onMessageFailed(WorkerMessageFailedEvent
$event): void
{ $stamp = ErrorDetailsStamp::
create($event->
getThrowable());
$previousStamp =
$event->
getEnvelope()->
last(ErrorDetailsStamp::
class);
// Do not append duplicate information
if (null ===
$previousStamp || !
$previousStamp->
equals($stamp)) { $event->
addStamps($stamp);
} } public static function getSubscribedEvents(): array
{ return [ // must have higher priority than SendFailedMessageForRetryListener
WorkerMessageFailedEvent::
class => ['onMessageFailed', 200
],
];
}}