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

Commit 2c69b68

Browse files
committed
TooManyRedirectsException is converted to a Network error
1 parent 946a126 commit 2c69b68

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/Guzzle6HttpAdapter.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function sendRequest(RequestInterface $request)
6161
*/
6262
private function handleTransferException(Guzzle\TransferException $exception)
6363
{
64-
if ($exception instanceof Guzzle\ConnectException) {
64+
if ($exception instanceof Guzzle\ConnectException || $exception instanceof Guzzle\TooManyRedirectsException) {
6565
return new NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
6666
}
6767

@@ -76,12 +76,6 @@ private function handleTransferException(Guzzle\TransferException $exception)
7676
);
7777
}
7878

79-
if ($exception instanceof Guzzle\TooManyRedirectsException) {
80-
// Do not convert TooManyRedirectsException
81-
return $exception;
82-
//return new HttpException($exception->getMessage(), $exception->getRequest(), null, $exception);
83-
}
84-
8579
return new RequestException($exception->getMessage(), $exception->getRequest(), $exception);
8680
}
8781

tests/Guzzle6HttpAdapterExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testGetException()
3232
$this->assertInstanceOf('Http\Client\Exception\NetworkException', $outputException, "Guzzle's ConnectException should be converted to a NetworkException");
3333

3434
$outputException = $method->invoke($adapter, new Guzzle\TooManyRedirectsException('foo', $request));
35-
$this->assertInstanceOf('GuzzleHttp\Exception\TooManyRedirectsException', $outputException, "Guzzle's TooManyRedirectsException should not be converted");
35+
$this->assertInstanceOf('Http\Client\Exception\NetworkException', $outputException, "Guzzle's TooManyRedirectsException should be converted to a NetworkException");
3636

3737
$outputException = $method->invoke($adapter, new Guzzle\RequestException('foo', $request, $response));
3838
$this->assertInstanceOf('Http\Client\Exception\HttpException', $outputException, "Guzzle's RequestException should be converted to a HttpException");

0 commit comments

Comments
 (0)