This commit is contained in:
2020-09-10 16:00:26 +08:00
parent 508eb0edc7
commit 80a89fe15a
+15 -2
View File
@@ -13,6 +13,7 @@ use HttpServer\Application;
use HttpServer\Route\Annotation\Annotation; use HttpServer\Route\Annotation\Annotation;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
use Snowflake\Core\JSON; use Snowflake\Core\JSON;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Coroutine; use Swoole\Coroutine;
@@ -425,9 +426,9 @@ class Router extends Application implements RouterInterface
$response = send($node->dispatch(), 200); $response = send($node->dispatch(), 200);
} }
} catch (ExitException $exception) { } catch (ExitException $exception) {
$response = send(Snowflake::app()->getLogger()->exception($exception), 200); $response = send($this->exception($exception), $exception->getCode());
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
$response = send(Snowflake::app()->getLogger()->exception($exception), 200); $response = send($this->exception($exception), 200);
} finally { } finally {
if (!($node instanceof Node) || !$node->hasAfter()) { if (!($node instanceof Node) || !$node->hasAfter()) {
return; 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 * @param Request $request
* @return Node|false|int|mixed|string|null * @return Node|false|int|mixed|string|null