Skip to content

Commit

Permalink
Handle DNS failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 10, 2018
1 parent 82779f2 commit bdd8b9c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Http/Client/Adapter/Curl.php
Expand Up @@ -16,6 +16,7 @@
use Cake\Http\Client\AdapterInterface;
use Cake\Http\Client\Request;
use Cake\Http\Client\Response;
use Cake\Http\Exception\HttpException;

/**
* Implements sending Cake\Http\Client\Request
Expand All @@ -33,8 +34,13 @@ public function send(Request $request, array $options)
curl_setopt_array($ch, $options);

$body = $this->exec($ch);
if ($body === false) {
$errorCode = curl_errno($ch);
$error = curl_error($ch);
curl_close($ch);
throw new HttpException("cURL Error ({$errorCode}) {$error}");
}

// TODO check for timeouts.
$responses = $this->createResponse($ch, $body);
curl_close($ch);

Expand Down

0 comments on commit bdd8b9c

Please sign in to comment.