This repository has been archived on 2022-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
lets/helpers/exceptionsTracker.py

18 lines
500 B
Python
Raw Permalink Normal View History

2018-12-09 05:15:56 +00:00
import sys
import traceback
from functools import wraps
from common.log import logUtils as log
def trackExceptions(moduleName=""):
def _trackExceptions(func):
def _decorator(request, *args, **kwargs):
try:
response = func(request, *args, **kwargs)
return response
except:
log.error("Unknown error{}!\n```\n{}\n{}```".format(" in "+moduleName if moduleName != "" else "", sys.exc_info(), traceback.format_exc()), True)
return wraps(func)(_decorator)
return _trackExceptions