Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
ad20ae9a
Commit
ad20ae9a
authored
Mar 10, 2016
by
Giorgos Korfiatis
Browse files
Fix handling of astakosclient errors
parent
d75bbed3
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/cmds/errors.py
View file @
ad20ae9a
...
...
@@ -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):
@
classmethod
def
astakosclient
(
this
,
func
):
def
_raise
(
self
,
*
args
,
**
kwargs
):
try
:
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
...
...
kamaki/clients/astakos/__init__.py
View file @
ad20ae9a
...
...
@@ -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
):
pass
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):
_log_astakosclient_request
(
self
)
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment