Skip to content

Commit c257cc4

Browse files
[HttpClient] throw DecodingExceptionInterface when toArray() fails because of content-type error
1 parent 2d6471c commit c257cc4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
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+
namespace Symfony\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 DecodingExceptionInterface extends ExceptionInterface
22+
{
23+
}

ResponseInterface.php

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

1414
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
15+
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
1516
use Symfony\Contracts\HttpClient\Exception\ExceptionInterface;
1617
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
1718
use Symfony\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)