feat: custom exceptions instead of direct fastapi.httpexceptions

Resolves #2
This commit is contained in:
Chris Milne 2026-05-27 14:58:10 +01:00
parent d3d3b2ca63
commit 868e56ce40
9 changed files with 73 additions and 43 deletions

View file

@ -4,4 +4,16 @@ Module specific exceptions for contact module
Exceptions:
- List: Description
- Exceptions: Description
"""
"""
from typing import Optional
from fastapi import HTTPException, status
class ContactNotFoundException(HTTPException):
def __init__(self, contact_id: Optional[int] = None) -> None:
detail = "Contact not found" if contact_id is None else f"Contact with ID '{contact_id}' was not found."
super().__init__(
status_code=status.HTTP_404_NOT_FOUND,
detail=detail,
)