|
10 | 10 | use Commercetools\Core\Helper\CorrelationIdProvider; |
11 | 11 | use Commercetools\Core\Response\AbstractApiResponse; |
12 | 12 | use GuzzleHttp\Client; |
| 13 | +use GuzzleHttp\ClientInterface; |
| 14 | +use GuzzleHttp\Exception\GuzzleException; |
13 | 15 | use GuzzleHttp\Exception\RequestException; |
| 16 | +use GuzzleHttp\Exception\TransferException; |
14 | 17 | use GuzzleHttp\HandlerStack; |
15 | 18 | use GuzzleHttp\MessageFormatter; |
16 | 19 | use GuzzleHttp\Middleware; |
@@ -154,6 +157,8 @@ public function execute(RequestInterface $request, array $clientOptions = []) |
154 | 157 | } catch (RequestException $exception) { |
155 | 158 | $response = $exception->getResponse(); |
156 | 159 | throw ApiException::create($request, $response, $exception); |
| 160 | + } catch (TransferException $exception) { |
| 161 | + throw ApiException::create($request, null, $exception); |
157 | 162 | } |
158 | 163 |
|
159 | 164 | return $response; |
@@ -182,7 +187,11 @@ public function executeBatch(array $requests, array $clientOptions = []) |
182 | 187 | $request = $requests[$key]; |
183 | 188 | $httpResponse = $result->getResponse(); |
184 | 189 | $httpResponse = ApiException::create($request, $httpResponse, $result); |
| 190 | + } elseif ($result instanceof TransferException) { |
| 191 | + $request = $requests[$key]; |
| 192 | + $httpResponse = ApiException::create($request, null, $result); |
185 | 193 | } |
| 194 | + |
186 | 195 | $responses[$key] = $httpResponse; |
187 | 196 | } |
188 | 197 |
|
@@ -225,7 +234,12 @@ public function executeAsync(RequestInterface $request, array $clientOptions = [ |
225 | 234 |
|
226 | 235 | public static function getAdapterInfo() |
227 | 236 | { |
228 | | - return 'GuzzleHttp/' . Client::VERSION; |
| 237 | + if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) { |
| 238 | + $clientVersion = (string) constant(Client::class . '::MAJOR_VERSION'); |
| 239 | + } else { |
| 240 | + $clientVersion = (string) constant(Client::class . '::VERSION'); |
| 241 | + } |
| 242 | + return 'GuzzleHttp/' . $clientVersion; |
229 | 243 | } |
230 | 244 |
|
231 | 245 | /** |
|
0 commit comments