exceptions.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:bdocker 作者: indigo-dc 项目源码 文件源码
def exception_from_response(response):
    """Manage exceptions from HTTP response.

    # Copyright 2014 CSIC Convert an OpenStack V2 Fault into a webob exception.
    # Copyright 2015 LIP Convert an OpenStack V2 Fault into a webob exception.
    Since we are calling the OpenStack API we should process the Faults
    produced by them. Extract the Fault information according to [1] and
    convert it back to a webob exception.
    [1] http://docs.openstack.org/developer/nova/v2/faults.html

    :param response: a webob.Response containing an exception
    :returns: a webob.exc.exception object
    """

    try:
        code = response.status_int
        title = response.json_body['results']
    except Exception:
        code = 500
        title = "Unknown error happened processing response"
    return manage_http_exception(code, title)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号