Improved the error message when a template is not found

This commit is contained in:
Javier Eguiluz 2016-01-19 09:57:11 +01:00
parent e9d951a882
commit 968476b707

View File

@ -89,10 +89,14 @@ class FilesystemLoader extends \Twig_Loader_Filesystem
} }
if (false === $file || null === $file) { if (false === $file || null === $file) {
list($namespace, $name) = $this->parseName($logicalName); try {
$paths = $this->getPaths($namespace); list($namespace, $name) = $this->parseName($logicalName);
array_walk($paths, function (&$path) use ($name) { $path .= '/'.$name; }); $paths = sprintf(' (looked into: %s)', implode(', ', $this->getPaths($namespace)));;
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" (tried: %s).', $name, implode(', ', $paths)), -1, null, $previous); } catch (\Twig_Error_Loader $e) {
$paths = '';
}
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s"%s.', $name, $paths, -1, null, $previous));
} }
return $this->cache[$logicalName] = $file; return $this->cache[$logicalName] = $file;