12345678910111213141516171819202122232425262728293031323334 |
- # -*- coding: utf-8 -*-
- # @Time : 2023/7/21 8:43
- # @Author : XuJiakai
- # @File : exception_handle
- # @Software: PyCharm
- from data_clean.exception.fetch_exception import FetchException
- from data_clean.exception.ruler_validation_exception import RulerValidationException
- from data_clean.utils.str_utils import pascal_case_to_snake_case
- from data_clean.utils import get_log
- log = get_log("exception_handler")
- def exception_handle(func):
- async def wrapper(self, *args, **kwargs):
- tn = pascal_case_to_snake_case(self.__class__.__name__)
- result = None
- try:
- result = await func(self, *args, **kwargs)
- except (FetchException, RulerValidationException) as ex:
- log.warn("%s", ex)
- pass
- except Exception as ex:
- log.error("出现未知异常:%s", ex)
- return result
- pass
- return wrapper
- if __name__ == '__main__':
- pass
|