4
4
5
5
namespace Http \Client \Common ;
6
6
7
- use Http \Client \Exception ;
8
7
use Http \Promise \Promise ;
8
+ use Psr \Http \Client \ClientExceptionInterface ;
9
9
use Psr \Http \Message \ResponseInterface ;
10
10
11
11
/**
@@ -19,7 +19,7 @@ final class Deferred implements Promise
19
19
private $ value ;
20
20
21
21
/**
22
- * @var Exception |null
22
+ * @var ClientExceptionInterface |null
23
23
*/
24
24
private $ failure ;
25
25
@@ -64,12 +64,12 @@ public function then(callable $onFulfilled = null, callable $onRejected = null):
64
64
$ response = $ onFulfilled ($ response );
65
65
}
66
66
$ deferred ->resolve ($ response );
67
- } catch (Exception $ exception ) {
67
+ } catch (ClientExceptionInterface $ exception ) {
68
68
$ deferred ->reject ($ exception );
69
69
}
70
70
};
71
71
72
- $ this ->onRejectedCallbacks [] = function (Exception $ exception ) use ($ onRejected , $ deferred ) {
72
+ $ this ->onRejectedCallbacks [] = function (ClientExceptionInterface $ exception ) use ($ onRejected , $ deferred ) {
73
73
try {
74
74
if (null !== $ onRejected ) {
75
75
$ response = $ onRejected ($ exception );
@@ -78,7 +78,7 @@ public function then(callable $onFulfilled = null, callable $onRejected = null):
78
78
return ;
79
79
}
80
80
$ deferred ->reject ($ exception );
81
- } catch (Exception $ newException ) {
81
+ } catch (ClientExceptionInterface $ newException ) {
82
82
$ deferred ->reject ($ newException );
83
83
}
84
84
};
@@ -114,7 +114,7 @@ public function resolve(ResponseInterface $response): void
114
114
/**
115
115
* Reject this deferred with an Exception.
116
116
*/
117
- public function reject (Exception $ exception ): void
117
+ public function reject (ClientExceptionInterface $ exception ): void
118
118
{
119
119
if (Promise::PENDING !== $ this ->state ) {
120
120
return ;
0 commit comments