|
5 | 5 | namespace Http\Client\Common\Plugin;
|
6 | 6 |
|
7 | 7 | use Http\Client\Common\Plugin;
|
8 |
| -use Http\Client\Exception; |
9 | 8 | use Http\Client\Exception\HttpException;
|
10 | 9 | use Http\Promise\Promise;
|
| 10 | +use Psr\Http\Client\ClientExceptionInterface; |
11 | 11 | use Psr\Http\Message\RequestInterface;
|
12 | 12 | use Psr\Http\Message\ResponseInterface;
|
13 | 13 | use Symfony\Component\OptionsResolver\OptionsResolver;
|
@@ -74,7 +74,7 @@ public function __construct(array $config = [])
|
74 | 74 | // do not retry client errors
|
75 | 75 | return $response->getStatusCode() >= 500 && $response->getStatusCode() < 600;
|
76 | 76 | },
|
77 |
| - 'exception_decider' => function (RequestInterface $request, Exception $e) { |
| 77 | + 'exception_decider' => function (RequestInterface $request, ClientExceptionInterface $e) { |
78 | 78 | // do not retry client errors
|
79 | 79 | return !$e instanceof HttpException || $e->getCode() >= 500 && $e->getCode() < 600;
|
80 | 80 | },
|
@@ -124,7 +124,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
|
124 | 124 | }
|
125 | 125 |
|
126 | 126 | return $response;
|
127 |
| - }, function (Exception $exception) use ($request, $next, $first, $chainIdentifier) { |
| 127 | + }, function (ClientExceptionInterface $exception) use ($request, $next, $first, $chainIdentifier) { |
128 | 128 | if (!array_key_exists($chainIdentifier, $this->retryStorage)) {
|
129 | 129 | $this->retryStorage[$chainIdentifier] = 0;
|
130 | 130 | }
|
@@ -156,7 +156,7 @@ public static function defaultErrorResponseDelay(RequestInterface $request, Resp
|
156 | 156 | /**
|
157 | 157 | * @param int $retries The number of retries we made before. First time this get called it will be 0.
|
158 | 158 | */
|
159 |
| - public static function defaultExceptionDelay(RequestInterface $request, Exception $e, int $retries): int |
| 159 | + public static function defaultExceptionDelay(RequestInterface $request, ClientExceptionInterface $e, int $retries): int |
160 | 160 | {
|
161 | 161 | return pow(2, $retries) * 500000;
|
162 | 162 | }
|
|
0 commit comments