Skip to content

Commit

Permalink
Indicate which file was being parsed if an exception is thrown while …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
mrthehud authored and fabpot committed Nov 2, 2014
1 parent 9ea4296 commit b1bffc0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
Expand Up @@ -58,7 +58,12 @@ public function extract($directory, MessageCatalogue $catalogue)
$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;
}
}
}

Expand Down

0 comments on commit b1bffc0

Please sign in to comment.