From 6c4ba79eeda07698e9533af58da4f117f3efd560 Mon Sep 17 00:00:00 2001 From: Johan Lundberg Date: Fri, 13 Feb 2026 13:14:01 +0100 Subject: [PATCH] feat: add DuplicateError domain exception --- src/fastapi_oidc_op/store/exceptions.py | 2 ++ tests/test_store/test_exceptions.py | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 src/fastapi_oidc_op/store/exceptions.py create mode 100644 tests/test_store/test_exceptions.py diff --git a/src/fastapi_oidc_op/store/exceptions.py b/src/fastapi_oidc_op/store/exceptions.py new file mode 100644 index 0000000..870abb4 --- /dev/null +++ b/src/fastapi_oidc_op/store/exceptions.py @@ -0,0 +1,2 @@ +class DuplicateError(Exception): + """Raised when a create operation violates a uniqueness constraint.""" diff --git a/tests/test_store/test_exceptions.py b/tests/test_store/test_exceptions.py new file mode 100644 index 0000000..dd1ec9b --- /dev/null +++ b/tests/test_store/test_exceptions.py @@ -0,0 +1,7 @@ +from fastapi_oidc_op.store.exceptions import DuplicateError + + +def test_duplicate_error_is_exception() -> None: + error = DuplicateError("user already exists") + assert isinstance(error, Exception) + assert str(error) == "user already exists"