Skip to content

Commit

Permalink
[TwigBundle] made error message more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 5, 2011
1 parent e2ea634 commit 2ae5427
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php
Expand Up @@ -75,25 +75,23 @@ public function isFresh($name, $time)

protected function findTemplate($name)
{
if (!is_array($name)) {
$name = $this->parser->parse($name);
}
$tpl = is_array($name) ? $name : $this->parser->parse($name);

$key = md5(serialize($name));
$key = md5(serialize($tpl));
if (isset($this->cache[$key])) {
return $this->cache[$key];
}

$file = null;
$previous = null;
try {
$file = $this->locator->locate($name);
$file = $this->locator->locate($tpl);
} catch (\InvalidArgumentException $e) {
$previous = $e;
}

if (false === $file || null === $file) {
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $name), 0, null, $previous);
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', json_encode($name)), 0, null, $previous);
}

return $this->cache[$key] = $file;
Expand Down

0 comments on commit 2ae5427

Please sign in to comment.