Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 968476b

Browse files
committed
Improved the error message when a template is not found
1 parent e9d951a commit 968476b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ protected function findTemplate($template, $throw = true)
8989
}
9090

9191
if (false === $file || null === $file) {
92-
list($namespace, $name) = $this->parseName($logicalName);
93-
$paths = $this->getPaths($namespace);
94-
array_walk($paths, function (&$path) use ($name) { $path .= '/'.$name; });
95-
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" (tried: %s).', $name, implode(', ', $paths)), -1, null, $previous);
92+
try {
93+
list($namespace, $name) = $this->parseName($logicalName);
94+
$paths = sprintf(' (looked into: %s)', implode(', ', $this->getPaths($namespace)));;
95+
} catch (\Twig_Error_Loader $e) {
96+
$paths = '';
97+
}
98+
99+
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s"%s.', $name, $paths, -1, null, $previous));
96100
}
97101

98102
return $this->cache[$logicalName] = $file;

0 commit comments

Comments
 (0)