Skip to content

Commit bf567cb

Browse files
committed
Return 4xx Responses.
1 parent 7bbe462 commit bf567cb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Proxy.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Proxy;
44

5+
use GuzzleHttp\Exception\ClientException;
56
use Proxy\Adapter\AdapterInterface;
67
use Proxy\Exception\UnexpectedValueException;
78
use Psr\Http\Message\RequestInterface;
@@ -79,7 +80,11 @@ public function to($target)
7980
$stack = $this->filters;
8081

8182
$stack[] = function (RequestInterface $request, ResponseInterface $response, callable $next) {
82-
$response = $this->adapter->send($request);
83+
try {
84+
$response = $this->adapter->send($request);
85+
} catch (ClientException $ex) {
86+
$response = $ex->getResponse();
87+
}
8388

8489
return $next($request, $response);
8590
};

0 commit comments

Comments
 (0)