[TwigBundle] added previous exception when possible

This commit is contained in:
Fabien Potencier 2011-02-02 14:41:03 +01:00
parent f217022ad5
commit a204e0df7f

View File

@ -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;