The Twig runtime error is not very useful

Use the previous exception to provide more information
This commit is contained in:
Samuel Georges 2015-05-02 18:11:26 +10:00
parent f334be5116
commit 58ace7ee6c
1 changed files with 18 additions and 0 deletions

View File

@ -8,6 +8,8 @@ use Cms\Classes\Router;
use Cms\Classes\Controller;
use October\Rain\Exception\ErrorHandler as ErrorHandlerBase;
use October\Rain\Exception\ApplicationException;
use Twig_Error_Runtime;
use Exception;
/**
* System Error Handler, this class handles application exception events.
@ -17,6 +19,22 @@ use October\Rain\Exception\ApplicationException;
*/
class ErrorHandler extends ErrorHandlerBase
{
/**
* {@inheritDoc}
*/
public function handleException(Exception $proposedException)
{
// The Twig runtime error is not very useful
if (
$proposedException instanceof Twig_Error_Runtime &&
($previousException = $proposedException->getPrevious())
) {
$proposedException = $previousException;
}
return parent::handleException($proposedException);
}
/**
* We are about to display an error page to the user,
* if it is an ApplicationException, this event should be logged.