Skip to content

Commit

Permalink
Merge pull request #54 from hisamu/master
Browse files Browse the repository at this point in the history
Specific Exception on connection error
  • Loading branch information
nategood committed Oct 6, 2012
2 parents c678733 + c2f71e7 commit fcaa366
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/Httpful/Exception/ConnectionErrorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Httpful\Exception;

class ConnectionErrorException extends \Exception
{
}
6 changes: 4 additions & 2 deletions src/Httpful/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Httpful;

use Httpful\Exception\ConnectionErrorException;

/**
* Clean, simple class for sending HTTP requests
* in PHP.
Expand Down Expand Up @@ -156,7 +158,7 @@ public function doNotFollowRedirects()
/**
* Actually send off the request, and parse the response
* @return string|associative array of parsed results
* @throws \Exception when unable to parse or communicate w server
* @throws ConnectionErrorException when unable to parse or communicate w server
*/
public function send()
{
Expand All @@ -167,7 +169,7 @@ public function send()

if ($result === false) {
$this->_error(curl_error($this->_ch));
throw new \Exception('Unable to connect.');
throw new ConnectionErrorException('Unable to connect.');
}

$info = curl_getinfo($this->_ch);
Expand Down

0 comments on commit fcaa366

Please sign in to comment.