Skip to content

Commit 810a6e0

Browse files
committed
Make sure we catch all exceptions
1 parent d855a91 commit 810a6e0

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
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: 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

@@ -40,7 +39,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
4039
$journal->addSuccess($request, $response);
4140

4241
return $response;
43-
}, function (Exception $exception) use ($request, $journal) {
42+
}, function (\Exception $exception) use ($request, $journal) {
4443
$journal->addFailure($request, $exception);
4544

4645
throw $exception;

src/Plugin/Journal.php

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

33
namespace Http\Client\Common\Plugin;
44

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

@@ -25,7 +24,7 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons
2524
* Record a failed call.
2625
*
2726
* @param RequestInterface $request Request use to make the call
28-
* @param Exception $exception Exception returned by the call
27+
* @param \Exception $exception Exception returned by the call
2928
*/
30-
public function addFailure(RequestInterface $request, Exception $exception);
29+
public function addFailure(RequestInterface $request, \Exception $exception);
3130
}

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)