Backend: FastAPI app with health check, AppError hierarchy, stderr logging via LOG_LEVEL, ruff+pyright(strict) config, pytest passing. Frontend: SvelteKit (TS) with prettier, eslint, vitest (unit + component), adapter-node for self-hosted deployment on Zeus. Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
901 B
Python
41 lines
901 B
Python
"""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
|