You are here

protected function Twig_Template::displayWithErrorHandling in Translation template extractor 7.3

Same name and namespace in other branches
  1. 6.3 vendor/Twig/Template.php \Twig_Template::displayWithErrorHandling()
1 call to Twig_Template::displayWithErrorHandling()
Twig_Template::display in vendor/Twig/Template.php
Displays the template with the given context.

File

vendor/Twig/Template.php, line 378

Class

Twig_Template
Default base class for compiled templates.

Code

protected function displayWithErrorHandling(array $context, array $blocks = array()) {
  try {
    $this
      ->doDisplay($context, $blocks);
  } catch (Twig_Error $e) {
    if (!$e
      ->getTemplateFile()) {
      $e
        ->setTemplateFile($this
        ->getTemplateName());
    }

    // this is mostly useful for Twig_Error_Loader exceptions
    // see Twig_Error_Loader
    if (false === $e
      ->getTemplateLine()) {
      $e
        ->setTemplateLine(-1);
      $e
        ->guess();
    }
    throw $e;
  } catch (Exception $e) {
    throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e
      ->getMessage()), -1, $this
      ->getTemplateName(), $e);
  }
}