From eeab6d5078573ca4b1901d535f625c47307d4b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 19 Mar 2021 18:23:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Route/Node.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index b5cd32ee..48ae2699 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -581,13 +581,19 @@ class Node extends HttpService if (!is_array($this->handler)) { return $this->runWith(...func_get_args()); } - [$class, $method] = $this->handler; - /** @var HttpFilter $filter */ - $filter = Snowflake::app()->get('filter'); - $validator = $filter->check(get_class($class), $method); - if ($validator instanceof Validator && !$validator->validation()) { - return Json::to(401, $validator->getError()); + try { + [$class, $method] = $this->handler; + + /** @var HttpFilter $filter */ + $filter = Snowflake::app()->get('filter'); + $validator = $filter->check(get_class($class), $method); + if ($validator instanceof Validator && !$validator->validation()) { + return Json::to(401, $validator->getError()); + } + } catch (Throwable $throwable) { + $this->error($throwable->getMessage()); + return Json::to(401, $throwable->getMessage()); } return $this->runWith(...func_get_args());