[HttpClient] Throw JsonException instead of TransportException on empty response in Response::toArray()
This commit is contained in:
parent
a2f4342d08
commit
69547d9cfc
@ -137,7 +137,7 @@ trait ResponseTrait
|
||||
public function toArray(bool $throw = true): array
|
||||
{
|
||||
if ('' === $content = $this->getContent($throw)) {
|
||||
throw new TransportException('Response body is empty.');
|
||||
throw new JsonException('Response body is empty.');
|
||||
}
|
||||
|
||||
if (null !== $this->jsonData) {
|
||||
|
@ -35,6 +35,12 @@ class MockResponseTest extends TestCase
|
||||
|
||||
public function toArrayErrors()
|
||||
{
|
||||
yield [
|
||||
'content' => '',
|
||||
'responseHeaders' => [],
|
||||
'message' => 'Response body is empty.',
|
||||
];
|
||||
|
||||
yield [
|
||||
'content' => '{}',
|
||||
'responseHeaders' => ['content-type' => 'plain/text'],
|
||||
|
Reference in New Issue
Block a user