From 762ed2e04d35e14d63d62cf12923f623eec27231 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 15 May 2013 20:36:02 +0200 Subject: [PATCH] Display Name of HttpException instead of classname class name is alwarys HttpException, better display the name of the http error. --- yii/base/ErrorHandler.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yii/base/ErrorHandler.php b/yii/base/ErrorHandler.php index 44c2ca0..8340723 100644 --- a/yii/base/ErrorHandler.php +++ b/yii/base/ErrorHandler.php @@ -75,8 +75,11 @@ class ErrorHandler extends Component \Yii::$app->runAction($this->errorAction); } elseif (\Yii::$app instanceof \yii\web\Application) { if (!headers_sent()) { - $errorCode = $exception instanceof HttpException ? $exception->statusCode : 500; - header("HTTP/1.0 $errorCode " . get_class($exception)); + if ($exception instanceof HttpException) { + 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') { \Yii::$app->renderException($exception);