core: minor helpers for error handling

This commit is contained in:
Dima Gerasimov 2020-10-13 21:34:38 +01:00 committed by karlicoss
parent d059e4aaf4
commit fa5e181cf8
3 changed files with 16 additions and 0 deletions

View file

@ -51,3 +51,14 @@ def check_dataframe(f: FuncT) -> FuncT:
return wrapper # type: ignore[return-value]
# todo doctor: could have a suggesion to wrap dataframes with it?? discover by return type?
from typing import Dict, Any
from .error import extract_error_datetime
def error_to_row(e: Exception, *, dt_col: str='dt') -> Dict[str, Any]:
# TODO attach traceback?
edt = extract_error_datetime(e)
return {
'error': str(e),
dt_col : edt,
}