cloud-api/src/exceptions.py

29 lines
669 B
Python
Raw Normal View History

2026-04-06 12:41:49 +01:00
"""
Global exceptions
2026-05-29 09:47:37 +01:00
Exports:
- UnprocessableContentException
- ConflictException
"""
from typing import Optional
from fastapi import HTTPException, status
2026-05-29 09:47:37 +01:00
class UnprocessableContentException(HTTPException):
def __init__(self, message: Optional[str] = None) -> None:
2026-05-29 09:47:37 +01:00
detail = "Unprocessable content" if not message else message
super().__init__(
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=detail,
)
2026-05-29 09:47:37 +01:00
class ConflictException(HTTPException):
def __init__(self, message: Optional[str] = None) -> None:
detail = "Conflict" if not message else message
super().__init__(
status_code=status.HTTP_409_CONFLICT,
detail=detail,
)