From 82e6a9ed50667cb31588d5b84727e941e7563bb4 Mon Sep 17 00:00:00 2001 From: boston Date: Tue, 1 Feb 2022 19:22:21 +0300 Subject: [PATCH] Exception for empty response --- src/MetaHash.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MetaHash.php b/src/MetaHash.php index 0cc2f54..41e9159 100644 --- a/src/MetaHash.php +++ b/src/MetaHash.php @@ -324,7 +324,13 @@ private function query(string $url, string $method, array $params = []): array throw new RuntimeException('QueryTorrent Error: '.$response->getBody()->getContents()); } - return \json_decode($response->getBody()->getContents(), true); + $result = \json_decode($response->getBody()->getContents(), true); + + if ($result === null) { + throw new RuntimeException('QueryTorrent Error: Empty response'); + } + + return $result; } /**