diff --git a/src/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPass.php b/src/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPass.php index ba9bc78..9f069d3 100644 --- a/src/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPass.php +++ b/src/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPass.php @@ -47,7 +47,7 @@ public function process(ContainerBuilder $container): void if (!$this->allowMultiple) { foreach ($handlers as $class => $refs) { if (count($refs) > 1) { - throw new LogicException(sprintf('Only one handler is allowed for %s of type "%s".', $this->topic, $class)); + throw new LogicException(sprintf('Only one handler is allowed for %s of type "%s". However, %d were found: %s', $this->topic, $class, count($refs), implode(', ', $refs))); } } } diff --git a/tests/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPassTest.php b/tests/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPassTest.php index faf96b7..318bcac 100644 --- a/tests/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPassTest.php +++ b/tests/Bridge/Symfony/DependencyInjection/CompilerPass/MessageHandlersLocatorPassTest.php @@ -52,7 +52,7 @@ public function testMultipleMessageHandlingProcess(): void public function testInvalidSingleMessageHandlingProcess(): void { $this->expectException(LogicException::class); - $this->expectExceptionMessage('Only one handler is allowed for message of type "OpenSolid\Tests\Bus\Fixtures\MyMessage".'); + $this->expectExceptionMessage('Only one handler is allowed for message of type "OpenSolid\Tests\Bus\Fixtures\MyMessage". However, 2 were found: handler_1, handler_2'); $container = new ContainerBuilder(); $this->configureContainer($container, allowMultiple: false);