浏览代码

[DependencyInjection] enhanced error message

Fabien Potencier 14 年之前
父节点
当前提交
001af2ae4a
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

+ 9 - 0
src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

@@ -256,6 +256,15 @@ class YamlFileLoader extends FileLoader
             }
 
             if (!$this->container->hasExtension($namespace)) {
+                $extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions()));
+                throw new \InvalidArgumentException(sprintf(
+                    'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
+                    $namespace,
+                    $file,
+                    $namespace,
+                    $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'
+                ));
+
                 throw new \InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s).', $namespace, $file));
             }
         }