diff options
author | Wolfgang Müller | 2024-11-14 16:55:17 +0100 |
---|---|---|
committer | Wolfgang Müller | 2024-11-14 20:45:02 +0100 |
commit | 11d177eeaac042acb55c99edcb0c01c66cdda664 (patch) | |
tree | 89855ac6587c01670db300f9d99b36b83c0715d5 | |
parent | bddbb684fd8a5d6992f5b1fc809e1629ccb841c1 (diff) | |
download | hircine-11d177eeaac042acb55c99edcb0c01c66cdda664.tar.gz |
backend/lint: Properly chain exceptions
This fixes flake8-bugbear's B904 [1].
[1] https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/
-rw-r--r-- | src/hircine/api/inputs.py | 8 | ||||
-rw-r--r-- | src/hircine/plugins/scrapers/ehentai_api.py | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/hircine/api/inputs.py b/src/hircine/api/inputs.py index c88bcce..a9cf272 100644 --- a/src/hircine/api/inputs.py +++ b/src/hircine/api/inputs.py @@ -277,13 +277,13 @@ class ComicTagsUpdateInput(UpdateInputList): def parse_input(cls, id): try: return [int(i) for i in id.split(":")] - except ValueError: + except ValueError as err: raise APIException( InvalidParameterError( parameter="id", text="ComicTag ID must be specified as <namespace_id>:<tag_id>", ) - ) + ) from err @classmethod async def get_from_ids(cls, ids, ctx: MutationContext): @@ -383,13 +383,13 @@ class ComicTagsUpsertInput(UpsertInputList): raise ValueError() return namespace, tag - except ValueError: + except ValueError as err: raise APIException( InvalidParameterError( parameter="name", text="ComicTag name must be specified as <namespace>:<tag>", ) - ) + ) from err @classmethod async def get_from_names(cls, input, ctx: MutationContext, on_missing: OnMissing): diff --git a/src/hircine/plugins/scrapers/ehentai_api.py b/src/hircine/plugins/scrapers/ehentai_api.py index 70fcf57..3720b92 100644 --- a/src/hircine/plugins/scrapers/ehentai_api.py +++ b/src/hircine/plugins/scrapers/ehentai_api.py @@ -69,7 +69,7 @@ class EHentaiAPIScraper(Scraper): handler = ExHentaiHandler() yield from handler.scrape(response) - except json.JSONDecodeError: - raise ScrapeError("Could not parse JSON response") + except json.JSONDecodeError as err: + raise ScrapeError("Could not parse JSON response") from err else: raise ScrapeError(f"Request failed with status code {request.status_code}'") |