|
@@ -3,6 +3,8 @@
|
|
|
# @Author : XuJiakai
|
|
|
# @File : exception_handle
|
|
|
# @Software: PyCharm
|
|
|
+from functools import update_wrapper
|
|
|
+
|
|
|
from data_clean.api.mongo_api import insert_one
|
|
|
from data_clean.exception.fetch_exception import FetchException
|
|
|
from data_clean.exception.ruler_validation_exception import RulerValidationException
|
|
@@ -19,8 +21,9 @@ async def ruler_valid_exception_sink(ex: RulerValidationException, tn: str, data
|
|
|
:param data:
|
|
|
:return:
|
|
|
"""
|
|
|
- col = "a_data_clean_ruler_valid_exception"
|
|
|
+ col = "a_data_clean_ruler_valid_error"
|
|
|
doc = {
|
|
|
+ "ruler_code": ex.ruler_code,
|
|
|
"tn": tn,
|
|
|
"exception": str(ex),
|
|
|
"data": data
|
|
@@ -37,7 +40,7 @@ async def fetch_exception_sink(ex: FetchException, tn: str, data: list):
|
|
|
:param data:
|
|
|
:return:
|
|
|
"""
|
|
|
- col_pre = "a_data_clean_fetch_exception"
|
|
|
+ col_pre = "a_data_clean_fetch_error"
|
|
|
|
|
|
doc = {
|
|
|
"tn": tn,
|
|
@@ -57,7 +60,6 @@ async def error_sink(ex: Exception, tn: str, data: list):
|
|
|
:return:
|
|
|
"""
|
|
|
col_pre = f"a_data_clean_error"
|
|
|
- col_pre += "_dim" if isinstance(data, list) else "_record"
|
|
|
doc = {
|
|
|
"tn": tn,
|
|
|
"exception": repr(ex),
|
|
@@ -76,19 +78,19 @@ def exception_handle(func):
|
|
|
try:
|
|
|
result = await func(self, *args, **kwargs)
|
|
|
except RulerValidationException as ex:
|
|
|
- log.warn("%s", ex)
|
|
|
+ log.warn("维度:%s ,detail: %s", tn, ex)
|
|
|
data = args[0]
|
|
|
if not isinstance(data, list):
|
|
|
data = [data]
|
|
|
await ruler_valid_exception_sink(ex, tn, data)
|
|
|
except FetchException as ex:
|
|
|
- log.error("%s", ex)
|
|
|
+ log.error("维度:%s ,detail: %s", tn, ex)
|
|
|
data = args[0]
|
|
|
if not isinstance(data, list):
|
|
|
data = [data]
|
|
|
await fetch_exception_sink(ex, tn, data)
|
|
|
except Exception as ex:
|
|
|
- log.error("出现未知异常:%s", repr(ex))
|
|
|
+ log.error("维度:%s ,出现未知异常:%s", tn, repr(ex))
|
|
|
data = args[0]
|
|
|
if not isinstance(data, list):
|
|
|
data = [data]
|
|
@@ -97,7 +99,7 @@ def exception_handle(func):
|
|
|
return result
|
|
|
pass
|
|
|
|
|
|
- return wrapper
|
|
|
+ return update_wrapper(wrapper, func)
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|