Commit 318d29b1 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

astakosclient: ReRaise json Exceptions as AstakosClient ones

parent 5299cc4d
......@@ -41,7 +41,7 @@ import simplejson
from astakosclient.utils import retry, scheme_to_class
from astakosclient.errors import \
AstakosClientException, Unauthorized, BadRequest, NotFound, Forbidden, \
NoUserName, NoUUID, BadValue, QuotaLimit
NoUserName, NoUUID, BadValue, QuotaLimit, InvalidResponse
# --------------------------------------------------------------------
......@@ -163,7 +163,14 @@ class AstakosClient():
raise NotFound(message, data)
elif status < 200 or status >= 300:
raise AstakosClientException(message, data, status)
return simplejson.loads(unicode(data))
if data:
return simplejson.loads(unicode(data))
return ""
except Exception as err:
raise InvalidResponse(str(err), data)
# ------------------------
# GET /im/authenticate
......@@ -49,6 +49,12 @@ class BadValue(AstakosClientException):
super(BadValue, self).__init__(message, details)
class InvalidResponse(AstakosClientException):
def __init__(self, message, details):
"""Return simplejson parse Exception as AstakosClient one"""
super(InvalidResponse, self).__init__(message, details)
class BadRequest(AstakosClientException):
status = 400
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