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;