accounting.calc: `.error()` on bad txn-time fields..

Since i'm seeing IB records with a `None` value and i don't want to be
debugging every time order-mode boots up..

Also use `pdb=debug` in `.open_ledger_dfs()`

Note, this had conflicts on `piker/accounting/calc.py` when rebasing
onto the refactored `brokers_refinery` history which were resolved
manually!
how_to_show_ur_pp
Tyler Goodlet 2025-10-02 12:17:57 -04:00
parent 58654915ac
commit 7b68444c7a
1 changed files with 23 additions and 11 deletions

View File

@ -294,7 +294,11 @@ def iter_by_dt(
)
continue
# XXX: should never get here..
# XXX: we should never really get here bc it means some kinda
# bad txn-record (field) data..
#
# -> set the `debug_mode = True` if you want to trace such
# cases from REPL ;)
else:
# XXX: we should really never get here..
# only if a ledger record has no expected sort(able)
@ -304,16 +308,21 @@ def iter_by_dt(
'No (time) sortable field for TXN:\n'
f'{tx!r}\n'
)
report: str = (
f'No supported time-field found in txn !?\n'
f'\n'
f'supported-time-fields: {parsers!r}\n'
f'\n'
f'txn: {tx!r}\n'
)
if debug:
import tractor
with tractor.devx.maybe_open_crash_handler():
raise ValueError(
f'No supported time-field found in txn !?\n'
f'\n'
f'supported-time-fields: {parsers!r}\n'
f'\n'
f'txn: {tx!r}\n'
)
with maybe_open_crash_handler(
pdb=debug,
raise_on_exit=False,
):
raise ValueError(report)
else:
log.error(report)
if _invalid is not None:
_invalid.append(tx)
@ -412,7 +421,10 @@ def open_ledger_dfs(
can update the ledger on exit.
'''
with maybe_open_crash_handler(pdb=debug_mode):
with maybe_open_crash_handler(
pdb=debug_mode,
# raise_on_exit=False,
):
if not ledger:
import time
from ._ledger import open_trade_ledger