From 2a12fdbcdf35f5cbc678d0d9beddae6f382203db Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 19 Apr 2013 03:51:08 +0400 Subject: [PATCH] safer exception rendering --- framework/base/ErrorHandler.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/framework/base/ErrorHandler.php b/framework/base/ErrorHandler.php index dc83474..91d5982 100644 --- a/framework/base/ErrorHandler.php +++ b/framework/base/ErrorHandler.php @@ -81,15 +81,20 @@ class ErrorHandler extends Component if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { \Yii::$app->renderException($exception); } else { - $view = new View; - if (!YII_DEBUG || $exception instanceof UserException) { - $viewName = $this->errorView; - } else { - $viewName = $this->exceptionView; + try { + $view = new View; + if (!YII_DEBUG || $exception instanceof UserException) { + $viewName = $this->errorView; + } else { + $viewName = $this->exceptionView; + } + echo $view->renderFile($viewName, array( + 'exception' => $exception, + ), $this); + } + catch (\Exception $e) { + \Yii::$app->renderException($e); } - echo $view->renderFile($viewName, array( - 'exception' => $exception, - ), $this); } } else { \Yii::$app->renderException($exception);