Automated Action 350b445f45 Implement task management tool with FastAPI and SQLite
- Setup project structure and FastAPI application
- Create SQLite database with SQLAlchemy
- Implement user authentication with JWT
- Create task and user models
- Add CRUD operations for tasks and users
- Configure Alembic for database migrations
- Implement API endpoints for task management
- Add error handling and validation
- Configure CORS middleware
- Create health check endpoint
- Add comprehensive documentation
2025-06-12 12:02:37 +00:00

53 lines
1.6 KiB
Python

from fastapi import HTTPException, status
class TaskManagementException(HTTPException):
def __init__(
self,
status_code: int,
detail: str = None,
) -> None:
super().__init__(status_code=status_code, detail=detail)
class NotFoundException(TaskManagementException):
def __init__(self, detail: str = "Item not found") -> None:
super().__init__(status_code=status.HTTP_404_NOT_FOUND, detail=detail)
class BadRequestException(TaskManagementException):
def __init__(self, detail: str = "Bad request") -> None:
super().__init__(status_code=status.HTTP_400_BAD_REQUEST, detail=detail)
class UnauthorizedException(TaskManagementException):
def __init__(self, detail: str = "Not authenticated") -> None:
super().__init__(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=detail,
)
class ForbiddenException(TaskManagementException):
def __init__(self, detail: str = "Not enough permissions") -> None:
super().__init__(status_code=status.HTTP_403_FORBIDDEN, detail=detail)
class EmailAlreadyExistsException(BadRequestException):
def __init__(self) -> None:
super().__init__("The user with this email already exists in the system")
class UsernameAlreadyExistsException(BadRequestException):
def __init__(self) -> None:
super().__init__("The username is already taken")
class InvalidCredentialsException(BadRequestException):
def __init__(self) -> None:
super().__init__("Incorrect email or password")
class InactiveUserException(BadRequestException):
def __init__(self) -> None:
super().__init__("Inactive user")