From 27d9385d4db3d29c5ca4900701da4a1a741f6d64 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Wed, 16 Jan 2013 09:01:02 +0100 Subject: [PATCH] wrap the exception to get information about where the exception comes from --- .../Compiler/ReplaceAliasByActualDefinitionPass.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php index 1964184955..972d708c59 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Reference; /** @@ -30,6 +31,8 @@ class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface * Process the Container to replace aliases with service definitions. * * @param ContainerBuilder $container + * + * @throws InvalidArgumentException if the service definition does not exist */ public function process(ContainerBuilder $container) { @@ -39,7 +42,11 @@ class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface foreach ($container->getAliases() as $id => $alias) { $aliasId = (string) $alias; - $definition = $container->getDefinition($aliasId); + try { + $definition = $container->getDefinition($aliasId); + } catch (InvalidArgumentException $e) { + throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with "%s".', $alias, $id), null, $e); + } if ($definition->isPublic()) { continue;