Skip to content

Commit

Permalink
Handle null response
Browse files Browse the repository at this point in the history
  • Loading branch information
dve committed Feb 25, 2018
1 parent 27a1fe3 commit fc9a117
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private function request(RequestInterface $request): ArrayFinder

$data = json_decode((string)$guzzleResponse->getBody(), true);

if(array_key_exists('error', $data)) {
if(is_null($data) || array_key_exists('error', $data)) {
throw new CexApiClientResponseException($guzzleResponse);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Exception/CexApiClientResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class CexApiClientResponseException extends \Exception
*/
private $response;

/**
* CexApiClientResponseException constructor.
* @param ResponseInterface $response
*/
public function __construct(ResponseInterface $response)
{
$this->response = $response;
Expand Down

0 comments on commit fc9a117

Please sign in to comment.