From a3835f508d4a441c64156d4669378e080064d4bf Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 3 Jun 2024 02:29:13 -0700 Subject: [PATCH] Use a specific Exception type --- Changelog | 1 + git_cache.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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]: -- 2.44.1