From 58577a01c867334e9af3ca69e57f8e61cf424e61 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 17 Sep 2021 06:41:14 +0545 Subject: [PATCH] Fix Guzzle7 exception handling in HttpRequestHelper --- tests/TestHelpers/HttpRequestHelper.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/TestHelpers/HttpRequestHelper.php b/tests/TestHelpers/HttpRequestHelper.php index b5d4759c5cca..e2e5c92e0299 100644 --- a/tests/TestHelpers/HttpRequestHelper.php +++ b/tests/TestHelpers/HttpRequestHelper.php @@ -25,7 +25,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Exception\BadResponseException; -use GuzzleHttp\Exception\GuzzleException; +use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\Request; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -109,9 +109,14 @@ public static function sendRequest( self::debugRequest($request, $user, $password); } + // The exceptions that might happen here include: + // ConnectException - in that case there is no response. Don't catch the exception. + // RequestException - if there is something in the response then pass it back. + // otherwise re-throw the exception. + // GuzzleException - something else unexpected happened. Don't catch the exception. try { $response = $client->send($request); - } catch (GuzzleException $ex) { + } catch (RequestException $ex) { $response = $ex->getResponse(); //if the response was null for some reason do not return it but re-throw