N°3522 Handle twig errors nicely

Revert what was done in c5021721 : I then added a panel to be rendered instead of throwing an Exception. This was done because the exception was displayed in a blank page... But this was caused simply by a missing `use Exception` !!

So now we're back at throwing an exception, so that the standard mechanism for throwing the error page is triggered.

Handling Twig recursion is mandatory, and done in the beginning of the \Combodo\iTop\Application\TwigBase\Twig\TwigHelper::RenderTemplate catch block to avoid adding on each stack level a useless exception.
This commit is contained in:
Pierre Goiffon
2021-03-11 11:26:06 +01:00
parent 4932a2cfbd
commit e49b0db58d
6 changed files with 37 additions and 38 deletions

View File

@@ -0,0 +1,17 @@
<?php
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
/**
* @since 3.0.0 N°3522
*/
class CoreTemplateException extends CoreException
{
public function __construct(Exception $oTwigException, string $sTemplatePath)
{
$sMessage = "Twig Exception when rendering '$sTemplatePath' : ".$oTwigException->getMessage();
parent::__construct($sMessage, null, '', $oTwigException);
}
}