Permalink
Browse files

wrap the exception to get information about where the exception comes…

… from
  • Loading branch information...
1 parent c401646 commit 74076fbb47bdb7e711c4bbe0580e054e087e3d05 @gimler gimler committed Jan 16, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 Compiler/ReplaceAliasByActualDefinitionPass.php
View
9 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 @@ public function process(ContainerBuilder $container)
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;

0 comments on commit 74076fb

Please sign in to comment.