【问题标题】:Catch Google Endpoint Response Error捕获 Google 端点响应错误
【发布时间】:2016-08-27 15:03:58
【问题描述】:

很难跟踪 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 本机代码。

谢谢

【问题讨论】:

  • 您知道触发错误的代码行吗?它不在回溯中。
  • @JohnGordon 这就是问题所在,Google Cloud Endpoints 内置代码引发的错误,无法在我的应用程序代码中捕获

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


【解决方案1】:

您可以使用 try except 结构来捕获错误。跟踪也可能对您有很大帮助。

try:
    //your code
Except ValidationError:
    raiseError

【讨论】:

  • 我知道。您可以检查您发送的参数。您可以查看 Endpoint 文档以获取更多信息。也许这有帮助。
猜你喜欢
  • 2019-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-29
  • 2019-04-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-05
相关资源
最近更新 更多