diff --git a/src/Httpful/Request.php b/src/Httpful/Request.php old mode 100644 new mode 100755 index 1de8ecc..147eec2 --- a/src/Httpful/Request.php +++ b/src/Httpful/Request.php @@ -201,7 +201,11 @@ public function send() $result = curl_exec($this->_ch); if ($result === false) { - $this->_error(curl_error($this->_ch)); + if ($curlErrorNumber = curl_errno($this->_ch)) { + $curlErrorString = curl_error($this->_ch); + throw new ConnectionErrorException('Unable to connect: '.$curlErrorNumber.' '.$curlErrorString); + } + throw new ConnectionErrorException('Unable to connect.'); } diff --git a/tests/Httpful/requestTest.php b/tests/Httpful/requestTest.php new file mode 100755 index 0000000..5977dcc --- /dev/null +++ b/tests/Httpful/requestTest.php @@ -0,0 +1,20 @@ + + */ +namespace Httpful\Test; + +class requestTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @author Nick Fox + * @expectedException Httpful\Exception\ConnectionErrorException + * @expectedExceptionMessage Unable to connect + */ + public function testGet_InvalidURL() + { + \Httpful\Request::get('unavailable.url')->send(); + } + +}