Spaces:
Running
Running
File size: 1,320 Bytes
fba6023 | 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 56 57 58 59 60 | 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
|