Doc*_*ent 6 python google-app-engine google-cloud-endpoints
Google自己的REST API会在出现错误时返回详细响应,例如:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidBookshelfId",
"message": "Invalid bookshelf ID."
}
],
"code": 400,
"message": "Invalid bookshelf ID."
}
}
Run Code Online (Sandbox Code Playgroud)
在Google Cloud Endpoints for Python中,有可能是例如raise endpoints.BadRequestException('Error message'),但除了错误消息之外,我还想返回"代码"或"原因",如上例所示.有没有办法实现这个目标?