Skip to content

Commit

Permalink
Fixed regression in exception handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic committed Apr 6, 2018
1 parent 3c13d91 commit c19bafc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ protected function parseUrl($config)
* Handles async request success.
*
* @param \Psr\Http\Message\ResponseInterface $response
* @param callable $callback
* @param callable|null $callback
*
* @return void
*/
protected function asyncFulfilled(ResponseInterface $response, callable $callback)
protected function asyncFulfilled(ResponseInterface $response, callable $callback = null)
{
$error = null;
if ($response->hasError()) {
Expand All @@ -263,11 +263,11 @@ protected function asyncFulfilled(ResponseInterface $response, callable $callbac
* Handles async request failure.
*
* @param \GuzzleHttp\Exception\RequestException $exception
* @param callable $callback
* @param callable|null $callback
*
* @return void
*/
protected function asyncRejected(RequestException $exception, callable $callback)
protected function asyncRejected(RequestException $exception, callable $callback = null)
{
if (
$exception->hasResponse() &&
Expand All @@ -278,10 +278,12 @@ protected function asyncRejected(RequestException $exception, callable $callback
);
}

$exception = new Exceptions\ClientException(
$exception->getMessage(),
$exception->getCode()
);
if ($exception instanceof RequestException) {
$exception = new Exceptions\ClientException(
$exception->getMessage(),
$exception->getCode()
);
}

if (is_callable($callback)) {
$callback($exception);
Expand Down

0 comments on commit c19bafc

Please sign in to comment.