"""Domain errors with a stable code (the contract of the old API, `app/api/errors.py`). `code` is what a page maps to its own text; `message` is plain English for logs and tests; `params` carries the values to place in the text (amounts as `*_sats`). """ from typing import Any class LedgerError(Exception): def __init__(self, code: str, message: str, **params: Any) -> None: super().__init__(message) self.code = code self.message = message self.params = params def as_dict(self) -> dict[str, Any]: return {"code": self.code, "message": self.message, "params": self.params}