From 767a78f8b8925563cd5c11e115813e84c7387f2a Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 19 Apr 2013 04:12:30 +0400 Subject: [PATCH] better handling of errors during rendering an error --- framework/base/Application.php | 2 +- framework/base/ErrorHandler.php | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/framework/base/Application.php b/framework/base/Application.php index 027dec8..c498a8e 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -411,7 +411,7 @@ class Application extends Module error_log($exception); if (($handler = $this->getErrorHandler()) !== null) { - @$handler->handle($exception); + $handler->handle($exception); } else { $this->renderException($exception); } diff --git a/framework/base/ErrorHandler.php b/framework/base/ErrorHandler.php index 91d5982..f9818ac 100644 --- a/framework/base/ErrorHandler.php +++ b/framework/base/ErrorHandler.php @@ -81,19 +81,22 @@ class ErrorHandler extends Component if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') { \Yii::$app->renderException($exception); } else { - 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); + if(YII_DEBUG) { + ini_set('display_errors', 1); } - catch (\Exception $e) { - \Yii::$app->renderException($e); + + $view = new View; + if (!YII_DEBUG || $exception instanceof UserException) { + $viewName = $this->errorView; + } else { + $viewName = $this->exceptionView; + } + echo $view->renderFile($viewName, array( + 'exception' => $exception, + ), $this); + + if(YII_DEBUG) { + ini_set('display_errors', 0); } } } else {