CI / lint (push) Successful in 58s
CI / security (push) Successful in 40s
CI / test (push) Successful in 1m15s
CI / build (push) Successful in 37s
CI / e2e (push) Successful in 10m15s
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
30 lines
844 B
Python
30 lines
844 B
Python
"""Domain errors shared by the reusable service layer.
|
|
|
|
Services are transport-agnostic: they raise :class:`ServiceError` carrying a
|
|
stable ``code`` and an HTTP ``status`` hint. The REST layer maps it to an
|
|
``HTTPException`` (via the global handler in ``backend.main``) while the tool
|
|
layer maps it to a :class:`backend.tools.context.ToolError`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
class ServiceError(Exception):
|
|
"""Base error for the shared business-logic services."""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str,
|
|
*,
|
|
code: str = "service_error",
|
|
status: int = 400,
|
|
details: dict[str, Any] | None = None,
|
|
):
|
|
super().__init__(message)
|
|
self.message = message
|
|
self.code = code
|
|
self.status = status
|
|
self.details = details or {}
|