core: minor error handling tweaks

This commit is contained in:
Dima Gerasimov 2020-10-18 12:09:27 +01:00 committed by karlicoss
parent 2a2478bfa9
commit 831fee42a1
3 changed files with 13 additions and 8 deletions

View file

@ -110,11 +110,13 @@ def test_sort_res_by() -> None:
# todo proper typevar?
from datetime import datetime
def set_error_datetime(e: Exception, dt: datetime) -> None:
def set_error_datetime(e: Exception, dt: Optional[datetime]) -> None:
if dt is None:
return
e.args = e.args + (dt,)
# todo not sure if should return new exception?
def attach_dt(e: Exception, *, dt: datetime) -> Exception:
def attach_dt(e: Exception, *, dt: Optional[datetime]) -> Exception:
set_error_datetime(e, dt)
return e