From bad57ba502bcb8ea846938e8dd0d2490854c3e1f Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Wed, 8 Dec 2021 16:02:21 -0800 Subject: [PATCH] feat(exceptions): add InvariantError This exception is to be used when a known invariant is violated. Signed-off-by: Kevin Morris --- aurweb/exceptions.py | 4 ++++ test/test_exceptions.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/aurweb/exceptions.py b/aurweb/exceptions.py index 31212676..1c45b7f3 100644 --- a/aurweb/exceptions.py +++ b/aurweb/exceptions.py @@ -86,3 +86,7 @@ class ValidationError(AurwebException): def __init__(self, data: Any, *args, **kwargs): super().__init__(*args, **kwargs) self.data = data + + +class InvariantError(AurwebException): + pass diff --git a/test/test_exceptions.py b/test/test_exceptions.py index 7247106b..e43cd645 100644 --- a/test/test_exceptions.py +++ b/test/test_exceptions.py @@ -97,3 +97,10 @@ def test_repository_name_exception(): raise exceptions.InvalidRepositoryNameException("test") except exceptions.InvalidRepositoryNameException as exc: assert str(exc) == "invalid repository name: test" + + +def test_invariant_error(): + try: + raise exceptions.InvariantError("test") + except exceptions.InvariantError as exc: + assert str(exc) == "test"