Skip to content

Commit 705c7c7

Browse files
committed
Make sure we catch all exceptions
1 parent d855a91 commit 705c7c7

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/HttpAsyncClientEmulator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Http\Client\Common;
44

5-
use Http\Client\Exception;
65
use Http\Promise;
76
use Psr\Http\Message\RequestInterface;
87

@@ -29,7 +28,7 @@ public function sendAsyncRequest(RequestInterface $request)
2928
{
3029
try {
3130
return new Promise\FulfilledPromise($this->sendRequest($request));
32-
} catch (Exception $e) {
31+
} catch (\Exception $e) {
3332
return new Promise\RejectedPromise($e);
3433
}
3534
}

src/Plugin/HistoryPlugin.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
4040
$journal->addSuccess($request, $response);
4141

4242
return $response;
43-
}, function (Exception $exception) use ($request, $journal) {
44-
$journal->addFailure($request, $exception);
43+
}, function (\Exception $exception) use ($request, $journal) {
44+
if ($exception instanceof Exception) {
45+
$journal->addFailure($request, $exception);
46+
}
4547

4648
throw $exception;
4749
});

src/Plugin/RetryPlugin.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Http\Client\Common\Plugin;
44

55
use Http\Client\Common\Plugin;
6-
use Http\Client\Exception;
76
use Psr\Http\Message\RequestInterface;
87
use Psr\Http\Message\ResponseInterface;
98
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -62,7 +61,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
6261
}
6362

6463
return $response;
65-
}, function (Exception $exception) use ($request, $next, $first, $chainIdentifier) {
64+
}, function (\Exception $exception) use ($request, $next, $first, $chainIdentifier) {
6665
if (!array_key_exists($chainIdentifier, $this->retryStorage)) {
6766
$this->retryStorage[$chainIdentifier] = 0;
6867
}

src/PluginClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Http\Client\Common;
44

55
use Http\Client\Common\Exception\LoopException;
6-
use Http\Client\Exception as HttplugException;
76
use Http\Client\HttpAsyncClient;
87
use Http\Client\HttpClient;
98
use Http\Promise\FulfilledPromise;
@@ -79,7 +78,7 @@ public function sendRequest(RequestInterface $request)
7978
$pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) {
8079
try {
8180
return new FulfilledPromise($this->client->sendRequest($request));
82-
} catch (HttplugException $exception) {
81+
} catch (\Exception $exception) {
8382
return new RejectedPromise($exception);
8483
}
8584
});

0 commit comments

Comments
 (0)