Преглед на файлове

merged branch lstrojny/master (PR #1555)

Commits
-------

133169f Better exception message for extension in XmlFileLoader

Discussion
----------

Better exception message for XmlFileLoader

Include namespace that has been looked for an registered namespaces in the exception message to ease debugging.
Fabien Potencier преди 14 години
родител
ревизия
907d2439cd
променени са 1 файла, в които са добавени 13 реда и са изтрити 1 реда
  1. 13 1
      src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

+ 13 - 1
src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

@@ -382,7 +382,19 @@ EOF
 
             // can it be handled by an extension?
             if (!$this->container->hasExtension($node->namespaceURI)) {
-                throw new \InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s).', $node->tagName, $file));
+                $extensionNamespaces = array_filter(array_map(
+                                            function($ext) {
+                                                return $ext->getNamespace();
+                                            },
+                                            $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',
+                    $node->tagName,
+                    $file,
+                    $node->namespaceURI,
+                    $extensionNamespaces ? '"' . join($extensionNamespaces, '", "') . '"' : 'none'
+                ));
             }
         }
     }