Skip to content

Commit

Permalink
[TASK] Throw exceptions in Client when response cannot be decoded
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Sep 6, 2015
1 parent bf260ee commit 767fb04
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Client.php
Expand Up @@ -16,7 +16,12 @@ class Client {
* @return string
*/
public function query(Query $query) {
return json_decode(file_get_contents($this->getEndpointUrl() . $query->toQueryString()), JSON_OBJECT_AS_ARRAY);
$body = file_get_contents($this->getEndpointUrl() . $query->toQueryString());
$decoded = json_decode($body, JSON_OBJECT_AS_ARRAY);
if (NULL === $decoded) {
throw new \RuntimeException($body);
}
return $decoded;
}

/**
Expand Down

0 comments on commit 767fb04

Please sign in to comment.