sagaphone/backend/app/errors.py

42 lines
901 B
Python
Raw Normal View History

"""Base exception hierarchy for the Sagaphone backend.
Errors propagate normally; only the API edge (see main.py's exception
handler) catches them and translates them into an HTTP response.
"""
from __future__ import annotations
class AppError(Exception):
"""Base class for all application errors."""
status_code: int = 500
def __init__(self, message: str) -> None:
super().__init__(message)
self.message = message
class NotFoundError(AppError):
"""Requested resource does not exist."""
status_code = 404
class ConfigError(AppError):
"""Missing or invalid configuration (e.g. secrets.toml)."""
status_code = 500
class NarrationError(AppError):
"""The narration (Haiku) call failed or returned something unusable."""
status_code = 502
class TTSError(AppError):
"""The TTS (Piper) synthesis step failed."""
status_code = 502