stopPropagation(); /** @var \Hyperf\Validation\ValidationException $throwable */ $body = json_encode([ 'code' => 0, 'msg' => $throwable->validator->errors()->first(), 'data' => null ], JSON_UNESCAPED_UNICODE); if (!$response->hasHeader('content-type')) { $response = $response->withAddedHeader('content-type', 'application/json; charset=utf-8'); } return $response->withStatus(200)->withBody(new SwooleStream($body)); } public function isValid(Throwable $throwable): bool { return $throwable instanceof ValidationException; } }