跳转到: 导航, 搜索

API 特别兴趣小组/当前设计/错误

分析

当 OpenStack 服务发生错误时,返回的内容非常不一致。 有的只返回状态码,有的返回 JSON,有的返回纯文本。

注意:似乎没有服务会返回顶级的 "errors" 键。

当前设计

测试错误的方法是简单地 GET 一个不存在的资源。 因此,下面所有的错误都是 404 错误。 下面收集的错误数量当然不全面,但即便如此,也清楚地表明了错误的非一致性。


计算

状态码:404

{
  "itemNotFound": {
    "message": "Instance could not be found",
    "code": 404
  }
}


身份认证

状态码:404

{
  "error": {
    "message": "Could not find user: does_not_exist",
    "code": 404,
    "title": "Not Found"
  }
}


Image

状态码:404

404 Not Found

The resource could not be found.

 Image with identifier does_not_exist not found


网络

状态码:404

404 Not Found

The resource could not be found.


Orchestration

状态码:404

{
  "explanation": "The resource could not be found.",
  "code": 404,
  "error": {
    "message": "The Stack (does_not_exist) could not be found.",
    "traceback": "Traceback (most recent call last):\n\n  File \"/opt/stack/heat/heat/engine/service.py\", line 69, in wrapped\n    return func(self, ctx, *args, **kwargs)\n\n  File \"/opt/stack/heat/heat/engine/service.py\", line 432, in identify_stack\n    raise exception.StackNotFound(stack_name=stack_name)\n\nStackNotFound: The Stack (does_not_exist) could not be found.\n",
    "type": "StackNotFound"
  },
  "title": "Not Found"
}


状态码:404

{
  "itemNotFound": {
    "message": "Volume could not be found",
    "code": 404
  }
}