my.core.serialize: implement default flag

Lots of surrounding changes from this discussion:
0593c69056

renamed/split error_to_json into error_to_row, moved
pandas-aware functions to my.core.pandas, leaving
generic ones in my.core.error.
This commit is contained in:
Sean Breckenridge 2021-03-18 03:04:49 -07:00
parent 0593c69056
commit c3f3650bcc
7 changed files with 172 additions and 36 deletions

View file

@ -145,15 +145,9 @@ def extract_error_datetime(e: Exception) -> Optional[datetime]:
import traceback
from .common import Json
def error_to_json(e: Exception, *, dt_col: str='dt', tz=None) -> Json:
edt = extract_error_datetime(e)
if edt is not None and edt.tzinfo is None and tz is not None:
edt = edt.replace(tzinfo=tz)
def error_to_json(e: Exception) -> Json:
estr = ''.join(traceback.format_exception(Exception, e, e.__traceback__))
return {
'error': estr,
dt_col : edt,
}
return {'error': estr}
def test_datetime_errors() -> None: