Skip to content

Commit e1591da

Browse files
committed
Use better exception in the register mapping pass
- When no manager name parameter found, throw a more informative exception.
1 parent b26ff03 commit e1591da

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass;
1313

14-
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
1514
use Symfony\Component\DependencyInjection\ContainerBuilder;
1615
use Symfony\Component\DependencyInjection\Definition;
1716
use Symfony\Component\DependencyInjection\Reference;
@@ -175,7 +174,7 @@ public function process(ContainerBuilder $container)
175174
*
176175
* @return string The name of the chain driver service
177176
*
178-
* @throws ParameterNotFoundException if non of the managerParameters has a
177+
* @throws InvalidArgumentException if non of the managerParameters has a
179178
* non-empty value.
180179
*/
181180
protected function getChainDriverServiceName(ContainerBuilder $container)
@@ -203,7 +202,7 @@ protected function getDriver(ContainerBuilder $container)
203202
*
204203
* @return string a service definition name
205204
*
206-
* @throws ParameterNotFoundException if none of the managerParameters has a
205+
* @throws InvalidArgumentException if none of the managerParameters has a
207206
* non-empty value.
208207
*/
209208
private function getConfigurationServiceName(ContainerBuilder $container)
@@ -221,7 +220,7 @@ private function getConfigurationServiceName(ContainerBuilder $container)
221220
*
222221
* @return string The name of the active manager.
223222
*
224-
* @throws ParameterNotFoundException If none of the managerParameters is found in the container.
223+
* @throws InvalidArgumentException If none of the managerParameters is found in the container.
225224
*/
226225
private function getManagerName(ContainerBuilder $container)
227226
{
@@ -234,7 +233,10 @@ private function getManagerName(ContainerBuilder $container)
234233
}
235234
}
236235

237-
throw new ParameterNotFoundException('Could not determine the Doctrine manager. Either Doctrine is not configured or a bundle is misconfigured.');
236+
throw new \InvalidArgumentException(sprintf(
237+
'Could not determine the manager name from the parameters, tried: "%s"',
238+
implode('", "', $this->managerParameters)
239+
));
238240
}
239241

240242
/**

0 commit comments

Comments
 (0)