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