44
55namespace Http \Client \Common ;
66
7- use Http \Client \Exception ;
87use Http \Promise \Promise ;
8+ use Psr \Http \Client \ClientExceptionInterface ;
99use 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