Browse Source

better handling of errors during rendering an error

tags/2.0.0-beta
Alexander Makarov 12 years ago
parent
commit
767a78f8b8
  1. 2
      framework/base/Application.php
  2. 27
      framework/base/ErrorHandler.php

2
framework/base/Application.php

@ -411,7 +411,7 @@ class Application extends Module
error_log($exception); error_log($exception);
if (($handler = $this->getErrorHandler()) !== null) { if (($handler = $this->getErrorHandler()) !== null) {
@$handler->handle($exception); $handler->handle($exception);
} else { } else {
$this->renderException($exception); $this->renderException($exception);
} }

27
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') { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
\Yii::$app->renderException($exception); \Yii::$app->renderException($exception);
} else { } else {
try { if(YII_DEBUG) {
$view = new View; ini_set('display_errors', 1);
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); $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 { } else {

Loading…
Cancel
Save