Display cURL error message in logs

This commit is contained in:
Frédéric Guillot 2019-06-04 15:57:07 -07:00
parent c81d9013d4
commit 4ebcf84d47
1 changed files with 6 additions and 4 deletions

View File

@ -265,14 +265,16 @@ class Client extends Base
$body = curl_exec($curlSession);
if (! $body) {
$this->logger->error('HttpClient: request failed ('.$url.')');
if ($body === false) {
$errorMsg = curl_error($curlSession);
curl_close($curlSession);
$this->logger->error('HttpClient: request failed ('.$url.' - '.$errorMsg.')');
if ($raiseForErrors) {
throw new ClientException('Unreachable URL: '.$url);
throw new ClientException('Unreachable URL: '.$url.' ('.$errorMsg.')');
}
curl_close($curlSession);
return '';
}