"""Доменные ошибки: единый carrier для SPA-роутов (→ HTTPException) и
MCP-тулов (→ данные {"error": code, "detail"} — канон handbook mcp.md)."""
class DomainError(Exception):
def __init__(self, code: int, detail: str) -> None:
super().__init__(detail)
self.code = code
self.detail = detail
def as_dict(exc: DomainError) -> dict:
return {"error": exc.code, "detail": exc.detail}