Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 0d7cfda

Browse files
committed
Wrap guzzle 3 request in try/catch
When running under xdebug, exceptions are thrown by the client, which we need to catch in order to retrieve the response.
1 parent e434e75 commit 0d7cfda

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Check/GuzzleHttpService.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use InvalidArgumentException;
1111
use Guzzle\Http\Client as Guzzle3Client;
1212
use Guzzle\Http\ClientInterface as Guzzle3ClientInterface;
13+
use Guzzle\Http\Exception\ClientErrorResponseException;
1314
use GuzzleHttp\Client as Guzzle456Client;
1415
use GuzzleHttp\ClientInterface as Guzzle456ClientInterface;
1516
use ZendDiagnostics\Result\Failure;
@@ -85,15 +86,19 @@ public function check()
8586
*/
8687
private function guzzle3Check()
8788
{
88-
$response = $this->guzzle
89-
->createRequest(
90-
$this->method,
91-
$this->url,
92-
$this->headers,
93-
$this->body,
94-
array_merge(['exceptions' => false], $this->options)
95-
)
96-
->send();
89+
try {
90+
$response = $this->guzzle
91+
->createRequest(
92+
$this->method,
93+
$this->url,
94+
$this->headers,
95+
$this->body,
96+
array_merge(['exceptions' => false], $this->options)
97+
)
98+
->send();
99+
} catch (ClientErrorResponseException $e) {
100+
$response = $e->getResponse();
101+
}
97102

98103
if ($this->statusCode !== ($statusCode = $response->getStatusCode())) {
99104
return $this->createStatusCodeFailure($statusCode);

0 commit comments

Comments
 (0)