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.
This commit is contained in:
James Hudson 2014-10-18 15:59:01 +01:00 committed by Fabien Potencier
parent 9ea4296028
commit b1bffc0516
1 changed files with 6 additions and 1 deletions

View File

@ -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;
}
}
}