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)
评论列表
文章目录