/**
* Handle a TwigError exception.
*
* @param \Twig_Error $ex
*
* @throws \Twig_Error|\ErrorException
*/
protected function handleTwigError(Twig_Error $ex)
{
$templateFile = $ex->getTemplateFile();
$templateLine = $ex->getTemplateLine();
if ($templateFile && file_exists($templateFile)) {
$file = $templateFile;
} elseif ($templateFile) {
// Attempt to locate full path to file
try {
$file = $this->loader->findTemplate($templateFile);
} catch (Twig_Error_Loader $exception) {
// Unable to load template
}
}
if (isset($file)) {
$ex = new ErrorException($ex->getMessage(), 0, 1, $file, $templateLine, $ex);
}
throw $ex;
}