Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bff9e68

Browse filesBrowse files
committed
feature #30567 [HttpClient] exceptions carry response (antonch1989)
This PR was squashed before being merged into the 4.3-dev branch (closes #30567). Discussion ---------- [HttpClient] exceptions carry response | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #30502 | License | MIT | Doc PR | Commits ------- 103448c [HttpClient] exceptions carry response
2 parents b15eee9 + 103448c commit bff9e68
Copy full SHA for bff9e68

File tree

5 files changed

+37
-3
lines changed
Filter options

5 files changed

+37
-3
lines changed

‎src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
*/
2121
trait HttpExceptionTrait
2222
{
23+
private $response;
24+
2325
public function __construct(ResponseInterface $response)
2426
{
27+
$this->response = $response;
2528
$code = $response->getInfo('http_code');
2629
$url = $response->getInfo('url');
2730
$message = sprintf('HTTP %d returned for URL "%s".', $code, $url);
@@ -35,4 +38,9 @@ public function __construct(ResponseInterface $response)
3538

3639
parent::__construct($message, $code);
3740
}
41+
42+
public function getResponse(): ResponseInterface
43+
{
44+
return $this->response;
45+
}
3846
}

‎src/Symfony/Contracts/HttpClient/Exception/ClientExceptionInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Contracts/HttpClient/Exception/ClientExceptionInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
*
1919
* @experimental in 1.1
2020
*/
21-
interface ClientExceptionInterface extends ExceptionInterface
21+
interface ClientExceptionInterface extends HttpExceptionInterface
2222
{
2323
}
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Contracts\HttpClient\Exception;
13+
14+
use Symfony\Contracts\HttpClient\ResponseInterface;
15+
16+
/**
17+
* Base interface for HTTP-related exceptions.
18+
*
19+
* @author Anton Chernikov <anton_ch1989@mail.ru>
20+
*
21+
* @experimental in 1.1
22+
*/
23+
interface HttpExceptionInterface extends ExceptionInterface
24+
{
25+
public function getResponse(): ResponseInterface;
26+
}

‎src/Symfony/Contracts/HttpClient/Exception/RedirectionExceptionInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Contracts/HttpClient/Exception/RedirectionExceptionInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
*
1919
* @experimental in 1.1
2020
*/
21-
interface RedirectionExceptionInterface extends ExceptionInterface
21+
interface RedirectionExceptionInterface extends HttpExceptionInterface
2222
{
2323
}

‎src/Symfony/Contracts/HttpClient/Exception/ServerExceptionInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Contracts/HttpClient/Exception/ServerExceptionInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
*
1919
* @experimental in 1.1
2020
*/
21-
interface ServerExceptionInterface extends ExceptionInterface
21+
interface ServerExceptionInterface extends HttpExceptionInterface
2222
{
2323
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.