Coverage for src/finbot/execution/errors.py: 100%
17 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-04 12:05 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-04 12:05 +0000
1class BrokerError(RuntimeError):
2 """Base error for broker operations"""
5class BrokerConnectionError(BrokerError):
6 """Raised when a broker cannot be reached"""
9class BrokerResponseError(BrokerError):
10 """Raised when a broker response cannot be mapped to the domain model."""
13class BrokerAPIError(BrokerError):
14 """Raised when a broker rejects an API request"""
16 def __init__(self, message: str, *, status_code: int):
17 super().__init__(message)
18 self.status_code = status_code
21class TradingDisabledError(BrokerError):
22 """Raised when order submission is attempted while trading is disabled."""
25class OrderConflictError(BrokerError):
26 """Raised when a client order ID refers to a different order."""
29class ReconciliationError(BrokerError):
30 """Raised when local and broker order state cannot be reconciled"""
32 def __init__(self, unresolved_client_order_ids: list[str]):
33 self.unresolved_client_order_ids = tuple(unresolved_client_order_ids)
34 joined = ", ".join(self.unresolved_client_order_ids)
36 super().__init__(f"Could not reconcile persisted orders: {joined}")
39class RuntimeNotReadyError(RuntimeError):
40 """Raised when trading is attempted before the execution runtime is ready."""
43class KillSwitchActiveError(RuntimeError):
44 """Raised when trading is attempted while the kill switch is active."""
47class RuntimeStoppedError(RuntimeError):
48 """Raised when an operation is attempted on a stopped execution runtime."""