Skip to content

Commit

Permalink
[HttpClient] Throw JsonException instead of TransportException on emp…
Browse files Browse the repository at this point in the history
…ty response in Response::toArray()
  • Loading branch information
jeroennoten committed Jun 2, 2020
1 parent a2f4342 commit 81c74a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -137,7 +137,7 @@ public function getContent(bool $throw = true): string
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) {
Expand Down
Expand Up @@ -35,6 +35,12 @@ public function testToArrayError($content, $responseHeaders, $message)

public function toArrayErrors()
{
yield [
'content' => '',
'responseHeaders' => [],
'message' => 'Response body is empty.',
];

yield [
'content' => '{}',
'responseHeaders' => ['content-type' => 'plain/text'],
Expand Down

0 comments on commit 81c74a3

Please sign in to comment.