Skip to content

Commit 27d9385

Browse files
committed
wrap the exception to get information about where the exception comes from
1 parent 2b3079f commit 27d9385

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1516
use Symfony\Component\DependencyInjection\Reference;
1617

1718
/**
@@ -30,6 +31,8 @@ class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface
3031
* Process the Container to replace aliases with service definitions.
3132
*
3233
* @param ContainerBuilder $container
34+
*
35+
* @throws InvalidArgumentException if the service definition does not exist
3336
*/
3437
public function process(ContainerBuilder $container)
3538
{
@@ -39,7 +42,11 @@ public function process(ContainerBuilder $container)
3942
foreach ($container->getAliases() as $id => $alias) {
4043
$aliasId = (string) $alias;
4144

42-
$definition = $container->getDefinition($aliasId);
45+
try {
46+
$definition = $container->getDefinition($aliasId);
47+
} catch (InvalidArgumentException $e) {
48+
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with "%s".', $alias, $id), null, $e);
49+
}
4350

4451
if ($definition->isPublic()) {
4552
continue;

0 commit comments

Comments
 (0)