Skip to content

Commit

Permalink
Add curl error message into exception when curl fails
Browse files Browse the repository at this point in the history
  • Loading branch information
slunak committed Mar 16, 2023
1 parent 0d7d288 commit 9712717
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Client/Curl/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ public static function do(Request $request)
curl_setopt_array($ch = curl_init(), $curlOptions);

$curlResponse = curl_exec($ch);
curl_close($ch);

if (false === $curlResponse) {
throw new LogicException('Curl request failed.');
throw new LogicException('Curl request failed. Curl error: ' . curl_error($ch));
}

if (true === $curlResponse) {
throw new LogicException('Curl should return json encoded string because CURLOPT_RETURNTRANSFER is set, "true" returned instead.');
}

curl_close($ch);

return $curlResponse;
}
}

0 comments on commit 9712717

Please sign in to comment.