mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-16 22:39:52 +08:00
Display Name of HttpException instead of classname
class name is alwarys HttpException, better display the name of the http error.
This commit is contained in:
@@ -75,8 +75,11 @@ class ErrorHandler extends Component
|
|||||||
\Yii::$app->runAction($this->errorAction);
|
\Yii::$app->runAction($this->errorAction);
|
||||||
} elseif (\Yii::$app instanceof \yii\web\Application) {
|
} elseif (\Yii::$app instanceof \yii\web\Application) {
|
||||||
if (!headers_sent()) {
|
if (!headers_sent()) {
|
||||||
$errorCode = $exception instanceof HttpException ? $exception->statusCode : 500;
|
if ($exception instanceof HttpException) {
|
||||||
header("HTTP/1.0 $errorCode " . get_class($exception));
|
header('HTTP/1.0 ' . $exception->statusCode . ' ' . $exception->getName());
|
||||||
|
} else {
|
||||||
|
header('HTTP/1.0 500 ' . get_class($exception));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user