From d4ab82c07e4b7cae46e3225187e658445dea7ff9 Mon Sep 17 00:00:00 2001 From: Kevo Date: Sun, 27 Feb 2022 18:21:46 +0100 Subject: [PATCH] Fix error handling --- piped_api/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/piped_api/client.py b/piped_api/client.py index ce54aa2..6ad9661 100644 --- a/piped_api/client.py +++ b/piped_api/client.py @@ -45,9 +45,9 @@ class PipedClient: - `**kwargs` - Additional keyword arguments to pass to `requests.Session.get` """ - json: dict = self.session.get(f"{self.base_api_url}{uri}", **kwargs).json() + json: t.Union[dict, list] = self.session.get(f"{self.base_api_url}{uri}", **kwargs).json() - if json.get('error', None) is not None: + if isinstance(json, dict) and json.get('error', None) is not None: raise APIError(f"Error: {json['error']}") if as_model is not None: