Update oslo-incubator apiclient.exceptions

Changes -
 * deprecate apiclient package
 * Handle different format of api exception
 * Split cliutils
 * Remove code that moved to oslo.i18n

Change-Id: Iba23b2153b9f7be6ea6efe7ff189080a96c45168
This commit is contained in:
Matthew Farrellee
2014-12-04 13:17:43 -05:00
parent d37a48ad48
commit f0fa95de32

View File

@@ -20,12 +20,25 @@
Exception definitions.
"""
########################################################################
#
# THIS MODULE IS DEPRECATED
#
# Please refer to
# https://etherpad.openstack.org/p/kilo-saharaclient-library-proposals for
# the discussion leading to this deprecation.
#
# We recommend checking out the python-openstacksdk project
# (https://launchpad.net/python-openstacksdk) instead.
#
########################################################################
import inspect
import sys
import six
from saharaclient.openstack.common.gettextutils import _
from saharaclient.openstack.common._i18n import _
class ClientException(Exception):
@@ -34,14 +47,6 @@ class ClientException(Exception):
pass
class MissingArgs(ClientException):
"""Supplied arguments are not sufficient for calling a function."""
def __init__(self, missing):
self.missing = missing
msg = _("Missing arguments: %s") % ", ".join(missing)
super(MissingArgs, self).__init__(msg)
class ValidationError(ClientException):
"""Error in validation on API client side."""
pass
@@ -447,10 +452,13 @@ def from_response(response, method, url):
except ValueError:
pass
else:
if isinstance(body, dict) and isinstance(body.get("error"), dict):
error = body["error"]
kwargs["message"] = error.get("message")
kwargs["details"] = error.get("details")
if isinstance(body, dict):
error = body.get(list(body)[0])
if isinstance(error, dict):
kwargs["message"] = (error.get("message") or
error.get("faultstring"))
kwargs["details"] = (error.get("details") or
six.text_type(body))
elif content_type.startswith("text/"):
kwargs["details"] = response.text