Browse Source

safer exception rendering

tags/2.0.0-beta
Alexander Makarov 12 years ago
parent
commit
2a12fdbcdf
  1. 21
      framework/base/ErrorHandler.php

21
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') { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
\Yii::$app->renderException($exception); \Yii::$app->renderException($exception);
} else { } else {
$view = new View; try {
if (!YII_DEBUG || $exception instanceof UserException) { $view = new View;
$viewName = $this->errorView; if (!YII_DEBUG || $exception instanceof UserException) {
} else { $viewName = $this->errorView;
$viewName = $this->exceptionView; } 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 { } else {
\Yii::$app->renderException($exception); \Yii::$app->renderException($exception);

Loading…
Cancel
Save