Skip to content

Commit 93da869

Browse files
authored
Catch decoding exceptions (#1053)
1 parent cce588a commit 93da869

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Response.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use AsyncAws\Core\Stream\ResultStream;
2222
use Psr\Log\LoggerInterface;
2323
use Psr\Log\LogLevel;
24+
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
2425
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
2526
use Symfony\Contracts\HttpClient\HttpClientInterface;
2627
use Symfony\Contracts\HttpClient\ResponseInterface;
@@ -316,6 +317,7 @@ public function getContent(): string
316317

317318
/**
318319
* @throws NetworkException
320+
* @throws UnparsableResponse
319321
* @throws HttpException
320322
*/
321323
public function toArray(): array
@@ -324,6 +326,8 @@ public function toArray(): array
324326

325327
try {
326328
return $this->httpResponse->toArray(false);
329+
} catch (DecodingExceptionInterface $e) {
330+
throw new UnparsableResponse('Could not parse response as array', 0, $e);
327331
} finally {
328332
$this->bodyDownloaded = true;
329333
}

0 commit comments

Comments
 (0)