Register all custom excs with `tractor` IPC

Call `reg_err_types()` for every piker-defined
exception so they can be marshalled and re-raised
across actor boundaries.

Deats,
- `brokers/_util.py`: auto-register `BrokerError` +
  all `__subclasses__()` (6 types).
- `config.py`: `ConfigurationError` +
  `__subclasses__()` (`NoSignature`).
- `data/validate.py`: `FeedInitializationError`.
- `service/_ahab.py`: `DockerNotStarted`,
  `ApplicationLogError`.
- `service/marketstore.py`: `MarketStoreError`.
- `storage/__init__.py`: `TimeseriesNotFound`,
  `StorageConnectionError`.
- `brokers/kraken/api.py`: `InvalidKey`.
- `brokers/kraken/broker.py`: `TooFastEdit`.
- `brokers/questrade.py`: `QuestradeError`.

Also,
- uncomment `execution_venue` field on kraken `Pair`.

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
repair_tests
Gud Boi 2026-03-20 20:40:31 -04:00
parent b30372f4fe
commit 75b73ee007
10 changed files with 46 additions and 1 deletions

View File

@ -28,6 +28,9 @@ import json
import httpx
import logging
from msgspec import Struct
from tractor._exceptions import (
reg_err_types,
)
from piker.log import (
colorize_json,
@ -107,6 +110,13 @@ class SchemaMismatch(BrokerError):
'''
# auto-register all `BrokerError` subtypes for
# tractor IPC exc-marshalling.
reg_err_types([
BrokerError,
*BrokerError.__subclasses__(),
])
def resproc(
resp: httpx.Response,

View File

@ -118,6 +118,9 @@ class InvalidKey(ValueError):
'''
from tractor._exceptions import reg_err_types
reg_err_types([InvalidKey])
class Client:

View File

@ -97,6 +97,9 @@ MsgUnion = Union[
class TooFastEdit(Exception):
'Edit requests faster then api submissions'
from tractor._exceptions import reg_err_types
reg_err_types([TooFastEdit])
# TODO: make this wrap the `Client` and `ws` instances
# and give it methods to submit cancel vs. add vs. edit

View File

@ -90,7 +90,7 @@ class Pair(Struct):
long_position_limit: float = float('inf')
# TODO, add API note when this was added!
# execution_venue: str|None = None
execution_venue: str|None = None
# TODO: should we make this a literal NamespacePath ref?
ns_path: str = 'piker.brokers.kraken:Pair'

View File

@ -95,6 +95,9 @@ _time_frames = {
class QuestradeError(Exception):
"Non-200 OK response code"
from tractor._exceptions import reg_err_types
reg_err_types([QuestradeError])
class ContractsKey(NamedTuple):
symbol: str

View File

@ -36,6 +36,7 @@ except ModuleNotFoundError:
import tomli as tomllib
from tractor._exceptions import reg_err_types
from .log import get_logger
log = get_logger('broker-config')
@ -172,6 +173,12 @@ class ConfigurationError(Exception):
class NoSignature(ConfigurationError):
'No credentials setup for broker backend!'
# auto-register for tractor IPC exc-marshalling.
reg_err_types([
ConfigurationError,
*ConfigurationError.__subclasses__(),
])
def _override_config_dir(
path: str

View File

@ -34,6 +34,7 @@ from piker.accounting import (
Asset,
MktPair,
)
from tractor._exceptions import reg_err_types
from ._util import log
@ -43,6 +44,8 @@ class FeedInitializationError(ValueError):
'''
reg_err_types([FeedInitializationError])
class FeedInit(Struct, frozen=True):
'''

View File

@ -49,6 +49,7 @@ from requests.exceptions import (
ReadTimeout,
)
from tractor._exceptions import reg_err_types
from piker.log import (
get_console_log,
get_logger,
@ -66,6 +67,11 @@ class DockerNotStarted(Exception):
class ApplicationLogError(Exception):
'App in container reported an error in logs'
reg_err_types([
DockerNotStarted,
ApplicationLogError,
])
@acm
async def open_docker(

View File

@ -382,6 +382,9 @@ def quote_to_marketstore_structarray(
class MarketStoreError(Exception):
"Generic marketstore client error"
from tractor._exceptions import reg_err_types
reg_err_types([MarketStoreError])
# def err_on_resp(response: dict) -> None:
# """Raise any errors found in responses from client request.

View File

@ -151,6 +151,13 @@ class StorageConnectionError(ConnectionError):
'''
from tractor._exceptions import reg_err_types
reg_err_types([
TimeseriesNotFound,
StorageConnectionError,
])
def get_storagemod(
name: str,