捕获Google端点响应错误

时间:2016-08-27 15:03:58

标签: python google-app-engine google-cloud-endpoints

很难跟踪Google Endpoints错误,该错误在回复时提出:

Encountered unexpected error from ProtoRPC method implementation: ValidationError (Message MatchCenterResponseMessage is missing required field sport) (/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/wsgi/service.py:191)
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/wsgi/service.py", line 182, in protorpc_service_app
    encoded_response = protocol.encode_message(response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/remote.py", line 1109, in encode_message
    return self.__protocol.encode_message(message)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/protojson.py", line 179, in encode_message
    message.check_initialized()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/messages.py", line 769, in check_initialized
    (type(self).__name__, name))
ValidationError: Message ResponseMessage is missing required field xyz

有没有办法从应用程序中捕获此异常?而不是来自Google Endpoint本机代码。

由于

1 个答案:

答案 0 :(得分:0)

您可以使用try except结构来捕获错误。跟踪也可以帮助你。

try:
    //your code
Except ValidationError:
    raiseError