request->path()); $result = match ($urlArr[0]) { 'api' => $this->apiReturn->error($throwable->validator->errors()->first()), 'admin', 'common' => $this->adminReturn->error($throwable->validator->errors()->first()), default => null, }; // 阻止异常冒泡 $this->stopPropagation(); if (!empty($result)) { return $response->withHeader("Content-Type", "application/json") ->withStatus(200) ->withBody(new SwooleStream(json_encode($result, JSON_UNESCAPED_UNICODE))); } } // 交给下一个异常处理器 return $response; } public function isValid(Throwable $throwable): bool { return true; } }