From 80a89fe15a08c69aa79e0ef08ea37eaf4fbf0c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 10 Sep 2020 16:00:26 +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/Router.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 53d57b44..cfe1851c 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -13,6 +13,7 @@ use HttpServer\Application; use HttpServer\Route\Annotation\Annotation; use Snowflake\Abstracts\Config; use Snowflake\Core\JSON; +use Snowflake\Exception\ComponentException; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; use Swoole\Coroutine; @@ -425,9 +426,9 @@ class Router extends Application implements RouterInterface $response = send($node->dispatch(), 200); } } catch (ExitException $exception) { - $response = send(Snowflake::app()->getLogger()->exception($exception), 200); + $response = send($this->exception($exception), $exception->getCode()); } catch (\Throwable $exception) { - $response = send(Snowflake::app()->getLogger()->exception($exception), 200); + $response = send($this->exception($exception), 200); } finally { if (!($node instanceof Node) || !$node->hasAfter()) { return; @@ -437,6 +438,18 @@ class Router extends Application implements RouterInterface } + /** + * @param $exception + * @return false|int|mixed|string + * @throws ComponentException + * @throws Exception + */ + private function exception($exception) + { + return Snowflake::app()->getLogger()->exception($exception); + } + + /** * @param Request $request * @return Node|false|int|mixed|string|null