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-coderepair_tests
parent
b30372f4fe
commit
75b73ee007
|
|
@ -28,6 +28,9 @@ import json
|
||||||
import httpx
|
import httpx
|
||||||
import logging
|
import logging
|
||||||
from msgspec import Struct
|
from msgspec import Struct
|
||||||
|
from tractor._exceptions import (
|
||||||
|
reg_err_types,
|
||||||
|
)
|
||||||
|
|
||||||
from piker.log import (
|
from piker.log import (
|
||||||
colorize_json,
|
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(
|
def resproc(
|
||||||
resp: httpx.Response,
|
resp: httpx.Response,
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,9 @@ class InvalidKey(ValueError):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
from tractor._exceptions import reg_err_types
|
||||||
|
reg_err_types([InvalidKey])
|
||||||
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,9 @@ MsgUnion = Union[
|
||||||
class TooFastEdit(Exception):
|
class TooFastEdit(Exception):
|
||||||
'Edit requests faster then api submissions'
|
'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
|
# TODO: make this wrap the `Client` and `ws` instances
|
||||||
# and give it methods to submit cancel vs. add vs. edit
|
# and give it methods to submit cancel vs. add vs. edit
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class Pair(Struct):
|
||||||
long_position_limit: float = float('inf')
|
long_position_limit: float = float('inf')
|
||||||
|
|
||||||
# TODO, add API note when this was added!
|
# 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?
|
# TODO: should we make this a literal NamespacePath ref?
|
||||||
ns_path: str = 'piker.brokers.kraken:Pair'
|
ns_path: str = 'piker.brokers.kraken:Pair'
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,9 @@ _time_frames = {
|
||||||
class QuestradeError(Exception):
|
class QuestradeError(Exception):
|
||||||
"Non-200 OK response code"
|
"Non-200 OK response code"
|
||||||
|
|
||||||
|
from tractor._exceptions import reg_err_types
|
||||||
|
reg_err_types([QuestradeError])
|
||||||
|
|
||||||
|
|
||||||
class ContractsKey(NamedTuple):
|
class ContractsKey(NamedTuple):
|
||||||
symbol: str
|
symbol: str
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ except ModuleNotFoundError:
|
||||||
import tomli as tomllib
|
import tomli as tomllib
|
||||||
|
|
||||||
|
|
||||||
|
from tractor._exceptions import reg_err_types
|
||||||
from .log import get_logger
|
from .log import get_logger
|
||||||
|
|
||||||
log = get_logger('broker-config')
|
log = get_logger('broker-config')
|
||||||
|
|
@ -172,6 +173,12 @@ class ConfigurationError(Exception):
|
||||||
class NoSignature(ConfigurationError):
|
class NoSignature(ConfigurationError):
|
||||||
'No credentials setup for broker backend!'
|
'No credentials setup for broker backend!'
|
||||||
|
|
||||||
|
# auto-register for tractor IPC exc-marshalling.
|
||||||
|
reg_err_types([
|
||||||
|
ConfigurationError,
|
||||||
|
*ConfigurationError.__subclasses__(),
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def _override_config_dir(
|
def _override_config_dir(
|
||||||
path: str
|
path: str
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ from piker.accounting import (
|
||||||
Asset,
|
Asset,
|
||||||
MktPair,
|
MktPair,
|
||||||
)
|
)
|
||||||
|
from tractor._exceptions import reg_err_types
|
||||||
from ._util import log
|
from ._util import log
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -43,6 +44,8 @@ class FeedInitializationError(ValueError):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
reg_err_types([FeedInitializationError])
|
||||||
|
|
||||||
|
|
||||||
class FeedInit(Struct, frozen=True):
|
class FeedInit(Struct, frozen=True):
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ from requests.exceptions import (
|
||||||
ReadTimeout,
|
ReadTimeout,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from tractor._exceptions import reg_err_types
|
||||||
from piker.log import (
|
from piker.log import (
|
||||||
get_console_log,
|
get_console_log,
|
||||||
get_logger,
|
get_logger,
|
||||||
|
|
@ -66,6 +67,11 @@ class DockerNotStarted(Exception):
|
||||||
class ApplicationLogError(Exception):
|
class ApplicationLogError(Exception):
|
||||||
'App in container reported an error in logs'
|
'App in container reported an error in logs'
|
||||||
|
|
||||||
|
reg_err_types([
|
||||||
|
DockerNotStarted,
|
||||||
|
ApplicationLogError,
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
@acm
|
@acm
|
||||||
async def open_docker(
|
async def open_docker(
|
||||||
|
|
|
||||||
|
|
@ -382,6 +382,9 @@ def quote_to_marketstore_structarray(
|
||||||
class MarketStoreError(Exception):
|
class MarketStoreError(Exception):
|
||||||
"Generic marketstore client error"
|
"Generic marketstore client error"
|
||||||
|
|
||||||
|
from tractor._exceptions import reg_err_types
|
||||||
|
reg_err_types([MarketStoreError])
|
||||||
|
|
||||||
|
|
||||||
# def err_on_resp(response: dict) -> None:
|
# def err_on_resp(response: dict) -> None:
|
||||||
# """Raise any errors found in responses from client request.
|
# """Raise any errors found in responses from client request.
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,13 @@ class StorageConnectionError(ConnectionError):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
from tractor._exceptions import reg_err_types
|
||||||
|
reg_err_types([
|
||||||
|
TimeseriesNotFound,
|
||||||
|
StorageConnectionError,
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def get_storagemod(
|
def get_storagemod(
|
||||||
name: str,
|
name: str,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue