diff options
author | Wolfgang Müller | 2024-11-15 14:13:24 +0100 |
---|---|---|
committer | Wolfgang Müller | 2024-11-15 14:13:24 +0100 |
commit | 9d27d52af9b852ac492f391fe69f5dd0a027c3cf (patch) | |
tree | 6adf0cfe3cc5f1b540361acb4324091370a5b628 /src | |
parent | 3b62b56c706622b7361e267d92f0408a29bee812 (diff) | |
download | hircine-9d27d52af9b852ac492f391fe69f5dd0a027c3cf.tar.gz |
backend/plugins: Throw error if E-Hentai response is missing 'gmetadata'
It might be that we get a valid (maybe empty) response from the API, in
which case we do not want to simply crash because we expect the
'gmetadata' field in the response. Instead, throw a proper ScrapeError
for it.
Diffstat (limited to 'src')
-rw-r--r-- | src/hircine/plugins/scrapers/ehentai_api.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/hircine/plugins/scrapers/ehentai_api.py b/src/hircine/plugins/scrapers/ehentai_api.py index d9d539d..d276c5b 100644 --- a/src/hircine/plugins/scrapers/ehentai_api.py +++ b/src/hircine/plugins/scrapers/ehentai_api.py @@ -71,5 +71,7 @@ class EHentaiAPIScraper(Scraper): yield from handler.scrape(response) except json.JSONDecodeError as err: raise ScrapeError("Could not parse JSON response") from err + except (KeyError, IndexError) as err: + raise ScrapeError("Response is missing 'gmetadata' field") from err else: raise ScrapeError(f"Request failed with status code {request.status_code}") |