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

@ -108,6 +108,9 @@ def set_error_datetime(e: Exception, dt: datetime) -> None:
e.args = e.args + (dt,)
# todo not sure if should return new exception?
def attach_dt(e: Exception, *, dt: datetime) -> Exception:
set_error_datetime(e, dt)
return e
# todo it might be problematic because might mess with timezones (when it's converted to string, it's converted to a shift)
def extract_error_datetime(e: Exception) -> Optional[datetime]: