From 4e8467b83030cb82fee7dd3f442efd9f80c4e5ab Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 24 Oct 2016 11:12:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=96=B0=E7=9A=84RouteNot?= =?UTF-8?q?FoundException=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 3 ++- .../exception/RouteNotFoundException.php | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 library/think/exception/RouteNotFoundException.php diff --git a/library/think/App.php b/library/think/App.php index ce7fd37a..ddb147f3 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -16,6 +16,7 @@ use think\Env; use think\Exception; use think\exception\HttpException; use think\exception\HttpResponseException; +use think\exception\RouteNotFoundException; use think\Hook; use think\Lang; use think\Loader; @@ -547,7 +548,7 @@ class App $must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must']; if ($must && false === $result) { // 路由无效 - throw new HttpException(404, 'Route Not Found'); + throw new RouteNotFoundException(); } } if (false === $result) { diff --git a/library/think/exception/RouteNotFoundException.php b/library/think/exception/RouteNotFoundException.php new file mode 100644 index 00000000..6ee2f7b6 --- /dev/null +++ b/library/think/exception/RouteNotFoundException.php @@ -0,0 +1,24 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use think\exception\HttpException; + +class RouteNotFoundException extends HttpException +{ + + public function __construct() + { + parent::__construct(404); + } + +}