getMessage(), $throwable->getLine(), $throwable->getFile()); $error_string = $throwable->getTraceAsString(); $this->logger->error($error); $this->logger->error($error_string); // 自定义日志通道 if ($this->app_debug) { $this->stdoutLog->log->error($error); $this->stdoutLog->log->error($error_string); } // 根据debug输出异常 $body = $this->app_debug ? "{$error}\n{$error_string}" : 'Internal Server Error.'; return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream($body)); } public function isValid(Throwable $throwable): bool { return true; } }