cloud-api/src/user/exceptions.py

24 lines
487 B
Python
Raw Normal View History

2026-04-06 12:41:49 +01:00
"""
2026-05-28 14:55:44 +01:00
Exceptions related to the user module
2026-04-06 12:41:49 +01:00
Exceptions:
2026-05-28 14:55:44 +01:00
- UserNotFoundException: Takes an optional user_id int
"""
from typing import Optional
from fastapi import HTTPException, status
class UserNotFoundException(HTTPException):
def __init__(self, user_id: Optional[int] = None) -> None:
detail = (
"User not found"
if user_id is None
else f"User with ID '{user_id}' was not found."
)
super().__init__(
status_code=status.HTTP_404_NOT_FOUND,
detail=detail,
)