From: Scott Worley Date: Mon, 3 Jun 2024 09:29:13 +0000 (-0700) Subject: Use a specific Exception type X-Git-Tag: v1.4.4~2 X-Git-Url: http://git.scottworley.com/git-cache/commitdiff_plain/a3835f508d4a441c64156d4669378e080064d4bf?ds=sidebyside Use a specific Exception type --- diff --git a/Changelog b/Changelog index 8569763..eeaebfb 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Use a specific Exception type ## [1.4.3] - 2023-05-24 diff --git a/git_cache.py b/git_cache.py index a34c329..8171b48 100644 --- a/git_cache.py +++ b/git_cache.py @@ -24,6 +24,11 @@ from typing import Iterator, NamedTuple, Optional, TypeVar, Tuple, Union import backoff + +class GitCacheError(Exception): + pass + + Path = str # eg: "/home/user/.cache/git-cache/v1" Repo = str # eg: "https://github.com/NixOS/nixpkgs.git" Ref = str # eg: "master" or "v1.0.0" @@ -85,7 +90,7 @@ def verify_ancestry( ancestor: RefOrRev, force: bool = False) -> None: if not force and not is_ancestor(repo, descendant, ancestor): - raise Exception(f'{ancestor} is not an ancestor of {descendant}') + raise GitCacheError(f'{ancestor} is not an ancestor of {descendant}') def _read_fetch_log(repo: Repo) -> Iterator[_LogEntry]: