File size: 1,845 Bytes
8ae78b0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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
) |