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

modify init and error msg, import problem

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