getMessage()); // 格式化输出 $data = json_encode([ 'code' => $throwable->getCode(), 'message' => $throwable->getMessage(), ], JSON_UNESCAPED_UNICODE); // 阻止异常冒泡 $this->stopPropagation(); return $response ->withAddedHeader('Content-Type', ' application/json; charset=UTF-8') ->withStatus(500) ->withBody(new SwooleStream($data)); } public function isValid(Throwable $throwable): bool { return true; } }