Files
simple-mensa/api/core/exceptions.py
T
Matteo Benedetto d592e0f32b feat: Refactor API structure and implement core functionalities
- Updated requirements to include asyncpg, pyyaml, aiofiles, and httpx.
- Modified schema.sql to add 'tipo_pasto' column in 'pasti' table.
- Created .gitignore file to exclude unnecessary files and directories.
- Added README.md for API implementation details and directory structure.
- Introduced config.yaml for centralized configuration management.
- Implemented core modules for database management, authentication, and exception handling.
- Developed models for 'pietanze', 'pasti', and 'prenotazioni' with validation.
- Created routes for CRUD operations on 'pietanze' with pagination and filtering.
- Established logging and error handling mechanisms throughout the application.
- Set up FastAPI application with CORS and health check endpoint.
2025-06-05 18:31:36 +02:00

23 lines
708 B
Python

from fastapi import HTTPException, status
class PietanzaNotFoundError(HTTPException):
def __init__(self, pietanza_id: int):
super().__init__(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Pietanza with id {pietanza_id} not found"
)
class ValidationError(HTTPException):
def __init__(self, detail: str):
super().__init__(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail=detail
)
class DatabaseError(HTTPException):
def __init__(self, detail: str = "Database operation failed"):
super().__init__(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=detail
)