diff --git a/src/OpenAi.php b/src/OpenAi.php index d9585a2..fba7dcc 100644 --- a/src/OpenAi.php +++ b/src/OpenAi.php @@ -968,10 +968,14 @@ private function sendRequest(string $url, string $method, array $opts = []) $info = curl_getinfo($curl); $this->curlInfo = $info; + if (! $response) { + $error = curl_error($curl); + } + curl_close($curl); - if (! $response) { - throw new Exception(curl_error($curl)); + if (! empty($error)) { + throw new Exception($error); } return $response;