Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit99c44a3

Browse files
committed
bug#32065 [HttpClient] throw DecodingExceptionInterface when toArray() fails because of content-type error (nicolas-grekas)
This PR was merged into the 4.3 branch.Discussion----------[HttpClient] throw DecodingExceptionInterface when toArray() fails because of content-type error| Q | A| ------------- | ---| Branch? | 4.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#31913| License | MIT| Doc PR | -As spotted in the linked issue, we are missing this type of exception. It's a bug at the contracts level.Commits-------3f16741 [HttpClient] throw DecodingExceptionInterface when toArray() fails because of content-type error
2 parentsdb15435 +3f16741 commit99c44a3

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespaceSymfony\Component\HttpClient\Exception;
1313

14-
useSymfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
14+
useSymfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
1515

1616
/**
1717
* Thrown by responses' toArray() method when their content cannot be JSON-decoded.
@@ -20,6 +20,6 @@
2020
*
2121
* @experimental in 4.3
2222
*/
23-
finalclass JsonExceptionextends \JsonExceptionimplementsTransportExceptionInterface
23+
finalclass JsonExceptionextends \JsonExceptionimplementsDecodingExceptionInterface
2424
{
2525
}

‎src/Symfony/Component/HttpClient/composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php":"^7.1.3",
2323
"psr/log":"^1.0",
24-
"symfony/http-client-contracts":"^1.1.3",
24+
"symfony/http-client-contracts":"^1.1.4",
2525
"symfony/polyfill-php73":"^1.11"
2626
},
2727
"require-dev": {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
namespaceSymfony\Contracts\HttpClient\Exception;
13+
14+
/**
15+
* When a content-type cannot be decoded to the expected representation.
16+
*
17+
* @author Nicolas Grekas <p@tchwork.com>
18+
*
19+
* @experimental in 1.1
20+
*/
21+
interface DecodingExceptionInterfaceextends ExceptionInterface
22+
{
23+
}

‎src/Symfony/Contracts/HttpClient/ResponseInterface.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespaceSymfony\Contracts\HttpClient;
1313

1414
useSymfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
15+
useSymfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
1516
useSymfony\Contracts\HttpClient\Exception\ExceptionInterface;
1617
useSymfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
1718
useSymfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
@@ -64,7 +65,8 @@ public function getContent(bool $throw = true): string;
6465
*
6566
* @param bool $throw Whether an exception should be thrown on 3/4/5xx status codes
6667
*
67-
* @throws TransportExceptionInterface When the body cannot be decoded or when a network error occurs
68+
* @throws DecodingExceptionInterface When the body cannot be decoded to an array
69+
* @throws TransportExceptionInterface When a network error occurs
6870
* @throws RedirectionExceptionInterface On a 3xx when $throw is true and the "max_redirects" option has been reached
6971
* @throws ClientExceptionInterface On a 4xx when $throw is true
7072
* @throws ServerExceptionInterface On a 5xx when $throw is true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp