modify
This commit is contained in:
@@ -515,11 +515,19 @@ class Node extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function dispatch(): mixed
|
public function dispatch(): mixed
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
Context::setContext('dispatch-param', func_get_args());
|
Context::setContext('dispatch-param', func_get_args());
|
||||||
if (empty($this->callback)) {
|
if (empty($this->callback)) {
|
||||||
return Json::to(404, $this->errorMsg());
|
return Json::to(404, $this->errorMsg());
|
||||||
}
|
}
|
||||||
return $this->httpFilter();
|
return $this->httpFilter();
|
||||||
|
} catch (Throwable $throwable) {
|
||||||
|
$this->addError($throwable, 'throwable');
|
||||||
|
|
||||||
|
$code = $throwable->getCode() == 0 ? 500 : $throwable->getCode();
|
||||||
|
|
||||||
|
return Json::to($code, $throwable->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -529,19 +537,11 @@ class Node extends HttpService
|
|||||||
*/
|
*/
|
||||||
private function httpFilter(): mixed
|
private function httpFilter(): mixed
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
if ($this->handler instanceof Closure) {
|
if ($this->handler instanceof Closure) {
|
||||||
return call_user_func($this->handler, \request());
|
return call_user_func($this->handler, \request());
|
||||||
} else {
|
} else {
|
||||||
return $this->runValidator([\request()]);
|
return $this->runValidator([\request()]);
|
||||||
}
|
}
|
||||||
} catch (Throwable $throwable) {
|
|
||||||
$this->addError($throwable, 'throwable');
|
|
||||||
|
|
||||||
$code = $throwable->getCode() == 0 ? 500 : $throwable->getCode();
|
|
||||||
|
|
||||||
return Json::to($code, $throwable->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user