Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prevent hide real exception when handler from some reason close conne…
…ction or transaction.
  • Loading branch information
lukaszjaworski-lab committed Feb 9, 2024
commit 014149968fd91d03a53d27f1abdb938b12182326
11 changes: 10 additions & 1 deletion Messenger/DoctrineTransactionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel

return $envelope;
} catch (\Throwable $exception) {
$entityManager->getConnection()->rollBack();
$this->tryRollBackTransaction($entityManager, $exception);

if ($exception instanceof HandlerFailedException) {
// Remove all HandledStamp from the envelope so the retry will execute all handlers again.
Expand All @@ -45,4 +45,13 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel
throw $exception;
}
}

private function tryRollBackTransaction(EntityManagerInterface $entityManager, \Throwable|\Exception $exception): void
{
try {
$entityManager->getConnection()->rollBack();
} catch (\Throwable $doctrineException) {
throw new HandlerFailedException($doctrineException->getMessage(), previous: $exception);
}
}
}