diff --git a/modules/system/classes/ErrorHandler.php b/modules/system/classes/ErrorHandler.php index bbe26204c..05d4094a6 100644 --- a/modules/system/classes/ErrorHandler.php +++ b/modules/system/classes/ErrorHandler.php @@ -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.