Skip to content

Commit

Permalink
Merge pull request #39251 from owncloud/issue-39250
Browse files Browse the repository at this point in the history
[tests-only] Fix Guzzle7 exception handling in HttpRequestHelper
  • Loading branch information
phil-davis authored Sep 17, 2021
2 parents 860794a + 58577a0 commit 1b22de1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/TestHelpers/HttpRequestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1b22de1

Please sign in to comment.