diff --git a/.travis.yml b/.travis.yml index 75969c0b..13ac73eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.3 - 5.4 - 5.5 - 5.6 diff --git a/composer.json b/composer.json index 520d7d9d..39e5c1d2 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ "homepage": "https://github.com/joomla-framework/github-api", "license": "GPL-2.0+", "require": { - "php": ">=5.3.10", + "php": ">=5.4", "joomla/date": "~1.0", - "joomla/http": "~1.0", + "joomla/http": "2.0.*@dev", "joomla/registry": "2.0.*@dev", "joomla/uri": "~1.0" }, diff --git a/src/AbstractGithubObject.php b/src/AbstractGithubObject.php index 93e6e39a..3b6eaf17 100644 --- a/src/AbstractGithubObject.php +++ b/src/AbstractGithubObject.php @@ -8,6 +8,7 @@ namespace Joomla\Github; +use Joomla\Http\Exception\UnexpectedResponseException; use Joomla\Http\Response; use Joomla\Uri\Uri; use Joomla\Registry\Registry; @@ -115,19 +116,22 @@ protected function fetchUrl($path, $page = 0, $limit = 0) * @return mixed * * @since 1.0 - * @throws \DomainException + * @throws UnexpectedResponseException */ protected function processResponse(Response $response, $expectedCode = 200) { // Validate the response code. - if ($response->code != $expectedCode) + if ($response->getStatusCode() != $expectedCode) { // Decode the error response and throw an exception. $error = json_decode($response->body); + + // Check if the error message is set; send a generic one if not $message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.'; - throw new \DomainException($message, $response->code); + + throw new UnexpectedResponseException($response, $message, $response->code); } - return json_decode($response->body); + return $response; } }