Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c03f5f

Browse files
committed
Throws UnrecoverableMessageHandlingException when passed invalid entity manager name for Doctrine middlewares
1 parent b319168 commit 8c03f5f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/Symfony/Bridge/Doctrine/Messenger/DoctrineClearEntityManagerMiddleware.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Doctrine\Messenger;
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
15-
use Doctrine\ORM\EntityManagerInterface;
1615
use Symfony\Component\Messenger\Envelope;
1716
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
1817
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
@@ -44,7 +43,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope
4443
try {
4544
$entityManager = $this->managerRegistry->getManager($this->entityManagerName);
4645
} catch (\InvalidArgumentException $e) {
47-
throw new UnrecoverableMessageHandlingException(sprintf('The ObjectManager with name "%s" must be an instance of EntityManagerInterface', $this->entityManagerName), 0, $e);
46+
throw new UnrecoverableMessageHandlingException($e->getMessage(), 0, $e);
4847
}
4948

5049
try {

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineClearEntityManagerMiddlewareTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public function testInvalidEntityManagerThrowsException()
5959

6060
$middleware = new DoctrineClearEntityManagerMiddleware($managerRegistry, 'unknown_manager');
6161

62-
$this->expectsException(UnrecoverableMessageHandlingException::class);
62+
$this->expectException(UnrecoverableMessageHandlingException::class);
6363

64-
$middleware->handle(new Envelope(new \stdClass()), $this->getStackMock());
64+
$middleware->handle(new Envelope(new \stdClass()), $this->getStackMock(false));
6565
}
6666
}

0 commit comments

Comments
 (0)