Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #15 from 99designs/features/improved_curl_error_me…
Browse files Browse the repository at this point in the history
…ssages

Provide more detail in exceptions resulting from curl errors
  • Loading branch information
rbone committed Feb 19, 2013
2 parents 76bb476 + a0af2f6 commit 50c5a9d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions classes/Ergo/Http/Transport.php
Expand Up @@ -17,10 +17,18 @@ public function send($request)
{
// prepare and send the curl request
$curl = $this->_curlConnection($request);
if(($curlResponse = curl_exec($curl)) === false)
$start = microtime(true);
$curlResponse = curl_exec($curl);
$total = microtime(true) - $start;
if ($curlResponse === false)
{
throw new Error('Curl error: ' . curl_error($curl),
curl_errno($curl));
throw new Error(sprintf(
'Curl error [errno: %d, url: %s, time: %.3fs): %s',
curl_errno($curl),
$request->getUrl(),
$total,
curl_error($curl)
));
}

$response = $this->_buildResponse($curlResponse);
Expand Down

0 comments on commit 50c5a9d

Please sign in to comment.