Skip to content

Commit 44bf9e3

Browse files
committed
Make sure we handle PSR-18 exceptions
1 parent f5143fe commit 44bf9e3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Deferred.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Http\Client\Common;
66

7-
use Http\Client\Exception;
87
use Http\Promise\Promise;
8+
use Psr\Http\Client\ClientExceptionInterface;
99
use Psr\Http\Message\ResponseInterface;
1010

1111
/**
@@ -19,7 +19,7 @@ final class Deferred implements Promise
1919
private $value;
2020

2121
/**
22-
* @var Exception|null
22+
* @var ClientExceptionInterface|null
2323
*/
2424
private $failure;
2525

@@ -64,12 +64,12 @@ public function then(callable $onFulfilled = null, callable $onRejected = null):
6464
$response = $onFulfilled($response);
6565
}
6666
$deferred->resolve($response);
67-
} catch (Exception $exception) {
67+
} catch (ClientExceptionInterface $exception) {
6868
$deferred->reject($exception);
6969
}
7070
};
7171

72-
$this->onRejectedCallbacks[] = function (Exception $exception) use ($onRejected, $deferred) {
72+
$this->onRejectedCallbacks[] = function (ClientExceptionInterface $exception) use ($onRejected, $deferred) {
7373
try {
7474
if (null !== $onRejected) {
7575
$response = $onRejected($exception);
@@ -78,7 +78,7 @@ public function then(callable $onFulfilled = null, callable $onRejected = null):
7878
return;
7979
}
8080
$deferred->reject($exception);
81-
} catch (Exception $newException) {
81+
} catch (ClientExceptionInterface $newException) {
8282
$deferred->reject($newException);
8383
}
8484
};
@@ -114,7 +114,7 @@ public function resolve(ResponseInterface $response): void
114114
/**
115115
* Reject this deferred with an Exception.
116116
*/
117-
public function reject(Exception $exception): void
117+
public function reject(ClientExceptionInterface $exception): void
118118
{
119119
if (Promise::PENDING !== $this->state) {
120120
return;

0 commit comments

Comments
 (0)