From 968476b707c75caf517519a47d8385d4dc23ec05 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 19 Jan 2016 09:57:11 +0100 Subject: [PATCH] Improved the error message when a template is not found --- .../Bundle/TwigBundle/Loader/FilesystemLoader.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 73e38cbe86..8b9f47b4de 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -89,10 +89,14 @@ class FilesystemLoader extends \Twig_Loader_Filesystem } if (false === $file || null === $file) { - list($namespace, $name) = $this->parseName($logicalName); - $paths = $this->getPaths($namespace); - array_walk($paths, function (&$path) use ($name) { $path .= '/'.$name; }); - throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" (tried: %s).', $name, implode(', ', $paths)), -1, null, $previous); + try { + list($namespace, $name) = $this->parseName($logicalName); + $paths = sprintf(' (looked into: %s)', implode(', ', $this->getPaths($namespace)));; + } 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;