Browse Source

[TwigBundle] added previous exception when possible

Fabien Potencier 14 years ago
parent
commit
a204e0df7f
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

+ 4 - 3
src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

@@ -85,14 +85,15 @@ class FilesystemLoader implements \Twig_LoaderInterface
         }
 
         $file = null;
+        $previous = null;
         try {
             $file = $this->locator->locate($name);
         } catch (\InvalidArgumentException $e) {
-            // File wasn't found, will throw twig load error
+            $previous = $e;
         }
 
-        if ($file === false || $file === null) {
-            throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $name));
+        if (false === $file || null === $file) {
+            throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $name), 0, $previous);
         }
 
         return $this->cache[$key] = $file;