awesome-fastapi-projects/populate/exceptions.py

15 lines
350 B
Python
Raw Normal View History

2021-11-17 09:10:33 +00:00
from typing import Any, Callable
from populate.logger import log
def ignore_exceptions(func: Callable):
def wrapper(*args: Any, **kwargs: Any):
try:
return func(*args, **kwargs)
except Exception:
log.exception(f"An exception has occurred on {func.__name__}")
return None
return wrapper