From b1bffc0516bd245cc75bd2a971e50c08801e1702 Mon Sep 17 00:00:00 2001 From: James Hudson Date: Sat, 18 Oct 2014 15:59:01 +0100 Subject: [PATCH] Indicate which file was being parsed if an exception is thrown while running translation:debug When running the translation:debug command, if a template contains invalid twig markup, an exception is thrown. This patch rethrows a new exception that includes the filename being parsed in the message to aid debuging. --- src/Symfony/Bridge/Twig/Translation/TwigExtractor.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php index a7fc89954e..b387b1c1c1 100644 --- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php +++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php @@ -58,7 +58,12 @@ class TwigExtractor implements ExtractorInterface $finder = new Finder(); $files = $finder->files()->name('*.twig')->in($directory); foreach ($files as $file) { - $this->extractTemplate(file_get_contents($file->getPathname()), $catalogue); + try { + $this->extractTemplate(file_get_contents($file->getPathname()), $catalogue); + } catch (\Twig_Error $e) { + $e->setTemplateFile($file->getPathname()); + throw $e; + } } }