Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific Exception on connection error #54

Merged
merged 2 commits into from
Oct 6, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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