public function setResponse()

in src/Response/Elasticsearch.php [64:84]


    public function setResponse(ResponseInterface $response, bool $throwException = true): void
    {
        $this->productCheck($response);
        // Check for Serverless response
        $this->serverless = $this->isServerlessResponse($response);
        $this->response = $response;
        $status = $response->getStatusCode();
        if ($throwException && $status > 399 && $status < 500) {
            $error = new ClientResponseException(
                sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()),
                $status
            );
            throw $error->setResponse($response);
        } elseif ($throwException && $status > 499 && $status < 600) {
            $error = new ServerResponseException(
                sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()),
                $status
            );
            throw $error->setResponse($response);
        }
    }