diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 68f25693..c260b5f4 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -7,6 +7,7 @@ use Closure; use Exception; use HttpServer\Abstracts\HttpService; use HttpServer\Controller; +use HttpServer\Exception\RequestException; use HttpServer\Http\Request; use HttpServer\Http\Response; use HttpServer\IInterface\Middleware; @@ -416,6 +417,7 @@ class Router extends HttpService implements RouterInterface * @param $method * @return Node|null * 查找指定路由 + * @throws RequestException */ public function tree_search(?array $explode, $method): ?Node { @@ -427,7 +429,7 @@ class Router extends HttpService implements RouterInterface while ($value = array_shift($explode)) { $node = $parent->findNode($value); if (!$node) { - break; + throw new RequestException('

HTTP 404 Not Found


Powered by Swoole', 404); } $parent = $node; }