Spaces:
Running
Running
| from __future__ import annotations | |
| from typing import Any | |
| class MediaAPIError(Exception): | |
| """A safe, client-facing application error.""" | |
| code = "MEDIA_API_ERROR" | |
| status_code = 400 | |
| def __init__(self, message: str, details: Any | None = None) -> None: | |
| super().__init__(message, details) | |
| self.message = message | |
| self.details = details | |
| def __str__(self) -> str: | |
| return self.message | |
| class InputError(MediaAPIError): | |
| code = "INVALID_INPUT" | |
| status_code = 422 | |
| class DownloadError(MediaAPIError): | |
| code = "DOWNLOAD_FAILED" | |
| status_code = 400 | |
| class ProcessingError(MediaAPIError): | |
| code = "PROCESSING_FAILED" | |
| status_code = 422 | |
| class NotFoundError(MediaAPIError): | |
| code = "NOT_FOUND" | |
| status_code = 404 | |
| class TemplateNotFoundError(MediaAPIError): | |
| """Raised when a requested template reference is unavailable.""" | |
| code = "TEMPLATE_NOT_FOUND" | |
| status_code = 404 | |
| class TemplateValidationError(MediaAPIError): | |
| """Raised when a template definition or runtime parameter is invalid.""" | |
| code = "INVALID_TEMPLATE" | |
| status_code = 422 | |
| class TemplateExecutionError(MediaAPIError): | |
| """Raised when a validated template cannot produce its declared output.""" | |
| code = "TEMPLATE_EXECUTION_FAILED" | |
| status_code = 422 | |