Commit ad20ae9a authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Fix handling of astakosclient errors

parent d75bbed3
......@@ -33,7 +33,6 @@
from traceback import format_exc, format_stack
from logging import getLogger
from astakosclient import AstakosClientException
from kamaki.clients import ClientError
from kamaki.cli import DEF_CLOUD_ENV
......@@ -125,12 +124,7 @@ class Astakos(object):
def astakosclient(this, func):
def _raise(self, *args, **kwargs):
r = func(self, *args, **kwargs)
except AstakosClientException as ace:
raise CLIError(
'Error in AstakosClient', details=['%s' % ace, ])
return r
return func(self, *args, **kwargs)
_raise.__name__ = func.__name__
return _raise
......@@ -48,11 +48,14 @@ from kamaki.clients.utils import https
log = getLogger(__name__)
class AstakosClientError(ClientError, AstakosClientException):
"""Join AstakosClientException as ClientError in one class"""
class AstakosClientError(ClientError):
def __init__(self, message='Astakos Client Error', details='', status=0):
super(ClientError, self).__init__(message, details, status)
def mk_astakosclienterror(sace):
"""Make an AstakosClientError from an AstakosClientException"""
return AstakosClientError(
message=sace.message, status=sace.status, details=sace.details)
def _log_astakosclient_request(cls):
......@@ -90,9 +93,7 @@ def _astakos_error(func):
if isinstance(getattr(sace, 'errobject', None), ssl.SSLError):
raise KamakiSSLError('SSL Connection error (%s)' % sace)
raise AstakosClientError(
getattr(sace, 'message', '%s' % sace),
details=sace.details, status=sace.status)
raise mk_astakosclienterror(sace)
return wrap
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment