my.core.serialize: orjson with additional default and _serialize hook (#140)
basic orjson serialize, json.dumps fallback
Lots of surrounding changes from this discussion:
0593c69056
This commit is contained in:
parent
02a9fb5e8f
commit
eb26cf8633
8 changed files with 224 additions and 24 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue