Commit ad218c67 by Qiang Xue

moved HttpException to web.

parent f14774df
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace yii\base; namespace yii\base;
use Yii; use Yii;
use yii\web\HttpException;
/** /**
* Application is the base class for all application classes. * Application is the base class for all application classes.
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace yii\base; namespace yii\base;
use Yii; use Yii;
use yii\web\HttpException;
/** /**
* ErrorHandler handles uncaught PHP errors and exceptions. * ErrorHandler handles uncaught PHP errors and exceptions.
......
...@@ -14,7 +14,7 @@ $context = $this->context; ...@@ -14,7 +14,7 @@ $context = $this->context;
<meta charset="utf-8"/> <meta charset="utf-8"/>
<title><?php <title><?php
if ($exception instanceof \yii\base\HttpException) { if ($exception instanceof \yii\web\HttpException) {
echo (int) $exception->statusCode . ' ' . $context->htmlEncode($exception->getName()); echo (int) $exception->statusCode . ' ' . $context->htmlEncode($exception->getName());
} elseif ($exception instanceof \yii\base\Exception) { } elseif ($exception instanceof \yii\base\Exception) {
echo $context->htmlEncode($exception->getName() . ' – ' . get_class($exception)); echo $context->htmlEncode($exception->getName() . ' – ' . get_class($exception));
...@@ -362,7 +362,7 @@ pre .diff .change{ ...@@ -362,7 +362,7 @@ pre .diff .change{
<?php else: ?> <?php else: ?>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAA6CAIAAACPssguAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREY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1t/ff0KegdH1v96yV7EEk7nU6r1bJtm+PrVPx9FyFQd7FYBMa+sLAwBODnMgirAAM+p/EqLDcuJAiwbaCsgU+fsf8vwADjle3ME1OGEwAAAABJRU5ErkJggg==" alt="Attention"/>
<h1><?php <h1><?php
if ($exception instanceof \yii\base\HttpException) { if ($exception instanceof \yii\web\HttpException) {
echo '<span>' . $context->createHttpStatusLink($exception->statusCode, $context->htmlEncode($exception->getName())) . '</span>'; echo '<span>' . $context->createHttpStatusLink($exception->statusCode, $context->htmlEncode($exception->getName())) . '</span>';
echo ' &ndash; ' . $context->addTypeLinks(get_class($exception)); echo ' &ndash; ' . $context->addTypeLinks(get_class($exception));
} elseif ($exception instanceof \yii\base\Exception) { } elseif ($exception instanceof \yii\base\Exception) {
......
...@@ -10,7 +10,7 @@ namespace yii\web; ...@@ -10,7 +10,7 @@ namespace yii\web;
use Yii; use Yii;
use yii\base\Action; use yii\base\Action;
use yii\base\ActionFilter; use yii\base\ActionFilter;
use yii\base\HttpException; use yii\web\HttpException;
/** /**
* AccessControl provides simple access control based on a set of rules. * AccessControl provides simple access control based on a set of rules.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace yii\web; namespace yii\web;
use Yii; use Yii;
use yii\base\HttpException; use yii\web\HttpException;
use yii\base\InvalidRouteException; use yii\base\InvalidRouteException;
/** /**
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace yii\web; namespace yii\web;
use Yii; use Yii;
use yii\base\HttpException; use yii\web\HttpException;
use yii\base\InlineAction; use yii\base\InlineAction;
/** /**
......
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\base; namespace yii\web;
use yii\base\UserException;
use yii\web\Response;
/** /**
* HttpException represents an exception caused by an improper request of the end-user. * HttpException represents an exception caused by an improper request of the end-user.
...@@ -42,9 +45,8 @@ class HttpException extends UserException ...@@ -42,9 +45,8 @@ class HttpException extends UserException
*/ */
public function getName() public function getName()
{ {
// use absolute namespaced class here because PHP will generate a mysterious error otherwise if (isset(Response::$httpStatuses[$this->statusCode])) {
if (isset(\yii\web\Response::$httpStatuses[$this->statusCode])) { return Response::$httpStatuses[$this->statusCode];
return \yii\web\Response::$httpStatuses[$this->statusCode];
} else { } else {
return 'Error'; return 'Error';
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace yii\web; namespace yii\web;
use Yii; use Yii;
use yii\base\HttpException; use yii\web\HttpException;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\helpers\SecurityHelper; use yii\helpers\SecurityHelper;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace yii\web; namespace yii\web;
use Yii; use Yii;
use yii\base\HttpException; use yii\web\HttpException;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
use yii\helpers\FileHelper; use yii\helpers\FileHelper;
use yii\helpers\Html; use yii\helpers\Html;
......
...@@ -9,7 +9,7 @@ namespace yii\web; ...@@ -9,7 +9,7 @@ namespace yii\web;
use Yii; use Yii;
use yii\base\Component; use yii\base\Component;
use yii\base\HttpException; use yii\web\HttpException;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
/** /**
......
...@@ -10,7 +10,7 @@ namespace yii\web; ...@@ -10,7 +10,7 @@ namespace yii\web;
use Yii; use Yii;
use yii\base\ActionEvent; use yii\base\ActionEvent;
use yii\base\Behavior; use yii\base\Behavior;
use yii\base\HttpException; use yii\web\HttpException;
/** /**
* VerbFilter is an action filter that filters by HTTP request methods. * VerbFilter is an action filter that filters by HTTP request methods.
...@@ -70,7 +70,7 @@ class VerbFilter extends Behavior ...@@ -70,7 +70,7 @@ class VerbFilter extends Behavior
/** /**
* @param ActionEvent $event * @param ActionEvent $event
* @return boolean * @return boolean
* @throws \yii\base\HttpException when the request method is not allowed. * @throws HttpException when the request method is not allowed.
*/ */
public function beforeAction($event) public function beforeAction($event)
{ {
......
...@@ -76,7 +76,7 @@ class ResponseTest extends \yiiunit\TestCase ...@@ -76,7 +76,7 @@ class ResponseTest extends \yiiunit\TestCase
*/ */
public function testSendFileWrongRanges($rangeHeader) public function testSendFileWrongRanges($rangeHeader)
{ {
$this->setExpectedException('yii\base\HttpException'); $this->setExpectedException('yii\web\HttpException');
$dataFile = \Yii::getAlias('@yiiunit/data/web/data.txt'); $dataFile = \Yii::getAlias('@yiiunit/data/web/data.txt');
$_SERVER['HTTP_RANGE'] = 'bytes=' . $rangeHeader; $_SERVER['HTTP_RANGE'] = 'bytes=' . $rangeHeader;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment