提交 6bd0c51e 编写于 作者: F felixhjh

modify init and error msg, import problem

上级 2d9abbc1
......@@ -29,8 +29,9 @@ import json
from .error_catch import ErrorCatch, CustomException, CustomExceptionCode, ParamChecker, ParamVerify
from .operator import Op, RequestOp, ResponseOp, VirtualOp
from .channel import (ThreadChannel, ProcessChannel, ChannelData,
ChannelDataErrcode, ChannelDataType, ChannelStopError,
ProductErrCode)
ChannelDataType, ChannelStopError)
from .error_catch import ProductErrCode
from .error_catch import CustomExceptionCode as ChannelDataErrcode
from .profiler import TimeProfiler, PerformanceTracer
from .util import NameGenerator, ThreadIdGenerator, PipelineProcSyncManager
from .proto import pipeline_service_pb2
......
......@@ -48,8 +48,9 @@ class CustomExceptionCode(enum.Enum):
class ProductErrCode(enum.Enum):
"""
ProductErrCode is a base class for recording business error code.
product developers overwrites this class and extend more error codes.
ProductErrCode is to record business error codes.
the ProductErrCode number ranges from 51 to 99
product developers can directly add error code into this class.
"""
pass
......@@ -105,13 +106,13 @@ class ErrorCatch():
_LOGGER.error("\nLog_id: {}\n{}Classname: {}\nFunctionName: {}\nArgs: {}".format(log_id, traceback.format_exc(), func.__qualname__, func.__name__, args))
split_list = re.split("\n|\t|:", str(e))
resp.err_no = int(split_list[3])
resp.err_msg = "Log_id: {} ErrNo: {} Error_msg: {} ClassName: {} FunctionName: {}".format(log_id, resp.err_no, split_list[9], func.__qualname__ ,func.__name__ )
resp.err_msg = "Log_id: {} Raise_msg: {} ClassName: {} FunctionName: {}".format(log_id, split_list[9], func.__qualname__ ,func.__name__ )
is_send_to_user = split_list[-1].replace(" ", "")
if is_send_to_user == "True":
return (None, resp)
else:
print("Erro_Num: {} {}".format(resp.err_no, resp.err_msg))
print("Init error occurs. For detailed information, Please look up log by log_id.")
print("Init error occurs. For detailed information. Please look up pipeline.log.wf in PipelineServingLogs by log_id.")
kill_stop_process_by_pid("kill", os.getpgid(os.getpid()))
except Exception as e:
if "log_id" in kw.keys():
......@@ -123,7 +124,7 @@ class ErrorCatch():
resp = pipeline_service_pb2.Response()
_LOGGER.error("\nLog_id: {}\n{}Classname: {}\nFunctionName: {}\nArgs: {}".format(log_id, traceback.format_exc(), func.__qualname__, func.__name__, args))
resp.err_no = CustomExceptionCode.UNKNOW.value
resp.err_msg = "Log_id: {} ErrNo: {} Error_msg: {} ClassName: {} FunctionName: {}".format(log_id, resp.err_no, str(e).replace("\'", ""), func.__qualname__ ,func.__name__ )
resp.err_msg = "Log_id: {} Raise_msg: {} ClassName: {} FunctionName: {}".format(log_id, str(e).replace("\'", ""), func.__qualname__ ,func.__name__ )
return (None, resp)
else:
resp = pipeline_service_pb2.Response()
......
......@@ -36,9 +36,10 @@ else:
from .error_catch import ErrorCatch, CustomException, CustomExceptionCode
from .proto import pipeline_service_pb2
from .channel import (ThreadChannel, ProcessChannel, ChannelDataErrcode,
ChannelData, ChannelDataType, ChannelStopError,
ChannelTimeoutError, ProductErrCode)
from .channel import (ThreadChannel, ProcessChannel,ChannelData,
ChannelDataType, ChannelStopError, ChannelTimeoutError)
from .error_catch import ProductErrCode
from .error_catch import CustomExceptionCode as ChannelDataErrcode
from .util import NameGenerator
from .profiler import UnsafeTimeProfiler as TimeProfiler
from . import local_service_handler
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册