test / behavior_backend /app /core /exceptions.py
hibatorrahmen's picture
Add backend application and Dockerfile
8ae78b0
from fastapi import HTTPException, status
class VideoNotFoundError(HTTPException):
"""Exception raised when a video is not found."""
def __init__(self, video_id: str):
super().__init__(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Video with ID {video_id} not found"
)
class ResultNotFoundError(HTTPException):
"""Exception raised when a processing result is not found."""
def __init__(self, video_id: str):
super().__init__(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Processing result for video with ID {video_id} not found"
)
class VideoUploadError(HTTPException):
"""Exception raised when there is an error uploading a video."""
def __init__(self, detail: str = "Error uploading video"):
super().__init__(
status_code=status.HTTP_400_BAD_REQUEST,
detail=detail
)
class VideoProcessingError(HTTPException):
"""Exception raised when there is an error processing a video."""
def __init__(self, detail: str = "Error processing video"):
super().__init__(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=detail
)
class InvalidParameterError(HTTPException):
"""Exception raised when a parameter is invalid."""
def __init__(self, parameter: str, detail: str = None):
super().__init__(
status_code=status.HTTP_400_BAD_REQUEST,
detail=detail or f"Invalid parameter: {parameter}"
)
class DatabaseError(HTTPException):
"""Exception raised when there is a database error."""
def __init__(self, detail: str = "Database error"):
super().__init__(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=detail
)