logger = $logger; } public function handle(Throwable $throwable, ResponseInterface $response) { // 判断是否是验证器异常类 if($throwable instanceof ValidateException){ return $response; } $this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); $this->logger->error($throwable->getTraceAsString()); return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); } public function isValid(Throwable $throwable): bool { return true; } }