From fbd6f85b9240c3d7b50702667a0c34b7918d3d86 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 18 Jul 2012 09:48:23 +0200 Subject: [PATCH] made Twig_Loader_Chain more explicit about problems --- CHANGELOG | 2 +- lib/Twig/Loader/Chain.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a58cc17..e4c4980 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.9.1 (2012-XX-XX) - * n/a + * made Twig_Loader_Chain more explicit about problems * 1.9.0 (2012-07-13) diff --git a/lib/Twig/Loader/Chain.php b/lib/Twig/Loader/Chain.php index a044905..b6b0ce9 100644 --- a/lib/Twig/Loader/Chain.php +++ b/lib/Twig/Loader/Chain.php @@ -51,14 +51,16 @@ class Twig_Loader_Chain implements Twig_LoaderInterface */ public function getSource($name) { + $exceptions = array(); foreach ($this->loaders as $loader) { try { return $loader->getSource($name); } catch (Twig_Error_Loader $e) { + $exceptions[] = $e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(', ', $exceptions))); } /** @@ -70,14 +72,16 @@ class Twig_Loader_Chain implements Twig_LoaderInterface */ public function getCacheKey($name) { + $exceptions = array(); foreach ($this->loaders as $loader) { try { return $loader->getCacheKey($name); } catch (Twig_Error_Loader $e) { + $exceptions[] = get_class($loader).': '.$e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions))); } /** @@ -88,13 +92,15 @@ class Twig_Loader_Chain implements Twig_LoaderInterface */ public function isFresh($name, $time) { + $exceptions = array(); foreach ($this->loaders as $loader) { try { return $loader->isFresh($name, $time); } catch (Twig_Error_Loader $e) { + $exceptions[] = get_class($loader).': '.$e->getMessage(); } } - throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); + throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions))); } } -- 1.7.2.5