diff --git a/src/HttpAsyncClientEmulator.php b/src/HttpAsyncClientEmulator.php index 9f527f4..4617c87 100644 --- a/src/HttpAsyncClientEmulator.php +++ b/src/HttpAsyncClientEmulator.php @@ -2,7 +2,6 @@ namespace Http\Client\Common; -use Http\Client\Exception; use Http\Promise; use Psr\Http\Message\RequestInterface; @@ -29,7 +28,7 @@ public function sendAsyncRequest(RequestInterface $request) { try { return new Promise\FulfilledPromise($this->sendRequest($request)); - } catch (Exception $e) { + } catch (\Exception $e) { return new Promise\RejectedPromise($e); } } diff --git a/src/Plugin/HistoryPlugin.php b/src/Plugin/HistoryPlugin.php index 5abddbd..84471b5 100644 --- a/src/Plugin/HistoryPlugin.php +++ b/src/Plugin/HistoryPlugin.php @@ -40,8 +40,10 @@ public function handleRequest(RequestInterface $request, callable $next, callabl $journal->addSuccess($request, $response); return $response; - }, function (Exception $exception) use ($request, $journal) { - $journal->addFailure($request, $exception); + }, function (\Exception $exception) use ($request, $journal) { + if ($exception instanceof Exception) { + $journal->addFailure($request, $exception); + } throw $exception; }); diff --git a/src/Plugin/RetryPlugin.php b/src/Plugin/RetryPlugin.php index bbb1ffa..c68b34b 100644 --- a/src/Plugin/RetryPlugin.php +++ b/src/Plugin/RetryPlugin.php @@ -3,7 +3,6 @@ namespace Http\Client\Common\Plugin; use Http\Client\Common\Plugin; -use Http\Client\Exception; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -62,7 +61,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl } return $response; - }, function (Exception $exception) use ($request, $next, $first, $chainIdentifier) { + }, function (\Exception $exception) use ($request, $next, $first, $chainIdentifier) { if (!array_key_exists($chainIdentifier, $this->retryStorage)) { $this->retryStorage[$chainIdentifier] = 0; } diff --git a/src/PluginClient.php b/src/PluginClient.php index 2e69ecf..3d4be1b 100644 --- a/src/PluginClient.php +++ b/src/PluginClient.php @@ -3,7 +3,6 @@ namespace Http\Client\Common; use Http\Client\Common\Exception\LoopException; -use Http\Client\Exception as HttplugException; use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use Http\Promise\FulfilledPromise; @@ -79,7 +78,7 @@ public function sendRequest(RequestInterface $request) $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { try { return new FulfilledPromise($this->client->sendRequest($request)); - } catch (HttplugException $exception) { + } catch (\Exception $exception) { return new RejectedPromise($exception); } });