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

Commit d7c08b6

Browse files
committed
TooManyRedirectsException is converted to a RequestException
1 parent 2c69b68 commit d7c08b6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Guzzle6HttpAdapter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use GuzzleHttp\Client;
1414
use GuzzleHttp\ClientInterface;
15-
use GuzzleHttp\Exception as Guzzle;
15+
use GuzzleHttp\Exception as GuzzleExceptions;
1616
use Http\Client\Exception\HttpException;
1717
use Http\Client\Exception\NetworkException;
1818
use Http\Client\Exception\RequestException;
@@ -45,27 +45,27 @@ public function sendRequest(RequestInterface $request)
4545
{
4646
try {
4747
return $this->client->send($request);
48-
} catch (Guzzle\SeekException $e) {
48+
} catch (GuzzleExceptions\SeekException $e) {
4949
throw new RequestException($e->getMessage(), $request, $e);
50-
} catch (Guzzle\TransferException $e) {
51-
throw $this->handleTransferException($e);
50+
} catch (GuzzleExceptions\GuzzleException $e) {
51+
throw $this->handleException($e);
5252
}
5353
}
5454

5555
/**
5656
* Converts a Guzzle exception into an Httplug exception.
5757
*
58-
* @param Guzzle\TransferException $exception
58+
* @param GuzzleExceptions\TransferException $exception
5959
*
6060
* @return RequestException
6161
*/
62-
private function handleTransferException(Guzzle\TransferException $exception)
62+
private function handleException(GuzzleExceptions\GuzzleException $exception)
6363
{
64-
if ($exception instanceof Guzzle\ConnectException || $exception instanceof Guzzle\TooManyRedirectsException) {
64+
if ($exception instanceof GuzzleExceptions\ConnectException) {
6565
return new NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
6666
}
6767

68-
if ($exception instanceof Guzzle\RequestException) {
68+
if ($exception instanceof GuzzleExceptions\RequestException) {
6969
// Make sure we have a response for the HttpException
7070
if ($exception->hasResponse()) {
7171
return new HttpException(

tests/Guzzle6HttpAdapterExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testGetException()
2525
$response = $this->getMock('Psr\Http\Message\ResponseInterface');
2626

2727
$adapter = new Guzzle6HttpAdapter();
28-
$method = new \ReflectionMethod('Http\Adapter\Guzzle6HttpAdapter', 'handleTransferException');
28+
$method = new \ReflectionMethod('Http\Adapter\Guzzle6HttpAdapter', 'handleException');
2929
$method->setAccessible(true);
3030

3131
$outputException = $method->invoke($adapter, new Guzzle\ConnectException('foo', $request));

0 commit comments

Comments
 (0)