This commit is contained in:
as2252258@163.com
2021-04-21 01:52:11 +08:00
parent 69908bcf72
commit 8e35c0e6d2
+16 -16
View File
@@ -515,11 +515,19 @@ class Node extends HttpService
*/
public function dispatch(): mixed
{
Context::setContext('dispatch-param', func_get_args());
if (empty($this->callback)) {
return Json::to(404, $this->errorMsg());
try {
Context::setContext('dispatch-param', func_get_args());
if (empty($this->callback)) {
return Json::to(404, $this->errorMsg());
}
return $this->httpFilter();
} catch (Throwable $throwable) {
$this->addError($throwable, 'throwable');
$code = $throwable->getCode() == 0 ? 500 : $throwable->getCode();
return Json::to($code, $throwable->getMessage());
}
return $this->httpFilter();
}
@@ -529,18 +537,10 @@ class Node extends HttpService
*/
private function httpFilter(): mixed
{
try {
if ($this->handler instanceof Closure) {
return call_user_func($this->handler, \request());
} else {
return $this->runValidator([\request()]);
}
} catch (Throwable $throwable) {
$this->addError($throwable, 'throwable');
$code = $throwable->getCode() == 0 ? 500 : $throwable->getCode();
return Json::to($code, $throwable->getMessage());
if ($this->handler instanceof Closure) {
return call_user_func($this->handler, \request());
} else {
return $this->runValidator([\request()]);
}
}