Skip to content

Updated the exceptions we are using #163

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

Merged
merged 1 commit into from
Jan 21, 2019
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
4 changes: 2 additions & 2 deletions src/Plugin/HistoryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Http\Client\Common\Plugin;

use Http\Client\Common\Plugin;
use Http\Client\Exception;
use Http\Promise\Promise;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand Down Expand Up @@ -40,7 +40,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
$journal->addSuccess($request, $response);

return $response;
}, function (Exception $exception) use ($request, $journal) {
}, function (ClientExceptionInterface $exception) use ($request, $journal) {
$journal->addFailure($request, $exception);

throw $exception;
Expand Down
8 changes: 4 additions & 4 deletions src/Plugin/Journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Http\Client\Common\Plugin;

use Http\Client\Exception;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand All @@ -26,8 +26,8 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons
/**
* Record a failed call.
*
* @param RequestInterface $request Request use to make the call
* @param Exception $exception Exception returned by the call
* @param RequestInterface $request Request use to make the call
* @param ClientExceptionInterface $exception Exception returned by the call
*/
public function addFailure(RequestInterface $request, Exception $exception);
public function addFailure(RequestInterface $request, ClientExceptionInterface $exception);
}
8 changes: 4 additions & 4 deletions src/Plugin/RetryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Http\Client\Common\Plugin;

use Http\Client\Common\Plugin;
use Http\Client\Exception;
use Http\Client\Exception\HttpException;
use Http\Promise\Promise;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function __construct(array $config = [])
// do not retry client errors
return $response->getStatusCode() >= 500 && $response->getStatusCode() < 600;
},
'exception_decider' => function (RequestInterface $request, Exception $e) {
'exception_decider' => function (RequestInterface $request, ClientExceptionInterface $e) {
// do not retry client errors
return !$e instanceof HttpException || $e->getCode() >= 500 && $e->getCode() < 600;
},
Expand Down Expand Up @@ -124,7 +124,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
}

return $response;
}, function (Exception $exception) use ($request, $next, $first, $chainIdentifier) {
}, function (ClientExceptionInterface $exception) use ($request, $next, $first, $chainIdentifier) {
if (!array_key_exists($chainIdentifier, $this->retryStorage)) {
$this->retryStorage[$chainIdentifier] = 0;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public static function defaultErrorResponseDelay(RequestInterface $request, Resp
/**
* @param int $retries The number of retries we made before. First time this get called it will be 0.
*/
public static function defaultExceptionDelay(RequestInterface $request, Exception $e, int $retries): int
public static function defaultExceptionDelay(RequestInterface $request, ClientExceptionInterface $e, int $retries): int
{
return pow(2, $retries) * 500000;
}
Expand Down